inmobi javascript return empty banner - javascript

I want to get a test ad banner from inmobi. According to inmobi Developer Wiki
http://developer.inmobi.com/wiki/index.php?title=JavaScript
this script
<script type="text/javascript">
var inmobi_conf = {
siteid : "4028cba631d63df10131e1d3191d00cb",
slot : "15",
test: "true"
};
</script><script type="text/javascript" src="http://cf.cdn.inmobi.com/ad/inmobi.js"></script>
must return test banner 320x50, but it always returns an empty banner.
Please help. What am I doing wrong?

You're getting "No-Fill Response". From that link you provided:
For example, if a publisher faces an NFR (No-Fill Response) scenario,
a callback is sent notifying that there is an NFR. The publisher can
now take steps to address and blank real estate issue that was caused
by non-availability of ads.
<div id="my-ad-slot">
<script type="text/javascript">
var inmobi_conf = {
siteid : "your site id",
slot : "slot number",
test: true,
onError : function(code) {
if(code == "nfr") {
document.getElementById("my-ad-slot").style.display = "none";
// do something else. call to other ad network or logic to display in-house ads, etc.
}
}
};
</script>
<script type="text/javascript" src="http://cf.cdn.inmobi.com/ad/inmobi.js"></script>
</div>
In the above code example, the parameter code will give nfr when no ads are returned.

Related

Javascript that displays table OR definition list. How do I control which one?

I've got some javascript provided by a scheduling site that shows a week of the schedule as a table on a laptop, but as a definition list on my iPhone 4, and then in a mobile emulator, as a table on an iPhone 5. It looks terrible as a table on mobile devices, and so I need to know how to control whether it shows up as a table or definition list.
Here's the script:
<div id="fs-embed-Khi8C7TGs4"></div>
<script type="text/javascript">
(function () {
(window.$fs || (window.$fs = [])).push(["embed", {
"root": "fs-embed-Khi8C7TGs4",
"host": "intuatouchmassage.fullslate.com",
"service": 1,
"employee": 189
}]);
if (!window.$fs._isFullSlate) {
var fsscr = document.createElement("script");
fsscr.type = "text/javascript";
fsscr.async = true;
fsscr.src = ["http", (document.location.protocol == "https:" ? "s" : ""), "://intuatouchmassage.fullslate.com/api.js"].join("");
var other = document.getElementsByTagName("script")[0];
other.parentNode.insertBefore(fsscr, other);
}
})();
</script>
<noscript>
<p>
<a title="Online scheduling" href="http://intuatouchmassage.fullslate.com/go/1/Massage-Therapy-60min?view=bare">Schedule appointment</a>
</p>
</noscript>
The outputs on both my computer and my phone are massive and ugly, and I couldn't even get it to display correctly on this site.
Any help would be immensely appreciated.
Also, this sometimes displays on phones, and sometimes comes up blank. Any ideas?

inmobi javascript call ad twice

According to inmobi Developer Wiki
http://developer.inmobi.com/wiki/index.php?title=JavaScript
You can call the Ads on Demand using manual: true parameter in the Var section:
E.g:
<script type="text/javascript" src="http://cf.cdn.inmobi.com/ad/inmobi.js">
</script>
<script type="text/javascript">
var inmobi_conf = {
siteid : "your site id",
slot : "slot number",
test: true,
manual: true
};
</script>
<div id="adArea"> </div>
To generate the Ad you have to call it using:
_inmobi.getNewAd(document.getElementById('adArea'));
it should populate the Ad.
I´ve created a simple test example to request an Ad on demand (using test siteid provided by inmobi).
The problem is that I have to click twice to load the Ad
Full Source:
<html>
<head>
<script>
var inmobi_conf = {
siteid : "4028cba631d63df10131e1d3191d00cb",
slot : "15",
test: true,
manual: true
};
function loadAdd(){
_inmobi.getNewAd(document.getElementById('screen'));
};
</script>
<script src="http://cf.cdn.inmobi.com/ad/inmobi.js"></script>
</head>
<body>
<div id="screen"> </div>
<button id="btn1" onClick="loadAdd()">Load Ad</button>
</body>
</html>
You can try it out on http://jsfiddle.net/YYzqA/
1st click on "Load Ad" button (no Ad)
2nd click on "Load Ab" button (the Ad will be loaded)
By chance do you know the reasons for this behavior? am I missing something?
You have set manual: true
you need to set it to manual: false for it to automatically set the configuration for you.
When you set manual: true, your first click is loading the configurations
Checkout the fiddle

Failed to load resource: 500 error in Salesforce when using a jQuery in sidebar component

As you all know that we cannot access custom labels (I might be wrong here) in sidebar component, like we do in vf pages({!$label.labelname}), I had to write a webService class in apex which will return the custom label and I use the sforce.apex.execute to access that class in jQuery script. Now, when the home page is loaded, the sidebar components load correctly and the below script executes without any problem. But when I enter some text in the textbox and search the text, myVfPage loads in a new tab with expected result, but again when I enter some text in the sidebar component and click on search I am not redirected to myVfPage. When I check the console in see 2 error which says:. This is what the error messages read:
1:- Failed to load resource: the server responded with a status of 500 (Internal Server Error)
2:-Uncaught {faultcode:'sf:INVALID_SESSION_ID', faultstring:'INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session', }
Not sure what to do here kindly help
<script type="text/javascript" src="/resource/jQuery"></script>
<script type="text/javascript" src="/resource/connection"></script>
<script type="text/javascript" src="/resource/apexjs" ></script>
<script type="text/javascript">
var j$ = jQuery.noConflict();
var sid = getCookie('sid');
var server = "https://"+window.location.host+"/services/Soap/u/26.0";
alert(server);
sforce.connection.init(sid, server);
var custLabelSearchText = sforce.apex.execute("JqueryCustomLabelController","getCustomLabel", {});
j$(document).ready(function(){
alert(getCookie('sid'));
j$("#searchIt").bind('click', function(){
if(j$("#userInput").val() == ''){
alert(custLabelSearchText);
custLabelSearchText ='';
}else{
window.open("/apex/myVfPage?searchText="+(j$("#userInput").val()), "_blank");
}
});
});
</script>
<b>Search your Text here</b><br/>
<input id="userInput" type="text"/><br/>
<input type="button" value="Search" id="searchIt"/>
I'm not sure, but try to insert session ID in the page header:
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>

How to trigger else clause in an onload event?

I have the Comments handle in my Google App Engine app to display the comments. I want to stop the page from loading if the user (defined as "chooser" here) is not in localStorage.
I get the first 2 alerts: "load event" and chooser: "undefined". Since "chooser" is undefined I expect the else clause to trigger but I don't get the alert in else clause.
Also, the first item in ordered list is displayed but not the rest. So I assume there is an issue with loading of the page. How can I fix this?
class Comments(webapp.RequestHandler):
def get(self):
self.response.out.write("""
<html>
<head>
<title>Choices</title>
<script type="text/javascript">
function showChoices ()
{
alert("load event");
var chooser = localStorage.getItem("chooser");
alert("chooser: " + chooser);
if (chooser)
{
document.getElementById("topten").style.display="inline";
}
else
{
alert("else triggers");
document.write("get an invitation");
}
}
window.onload = showChoices;
</script>
</head>
<body>
<div class="content">""")
#python code:
query = Users.all()
e = query.fetch(10)
self.response.out.write("""<ol>""")
for item in e:
self.response.out.write("""
<div id="topten" class="title" style="display:none">
<li>%s (<span class="small">%s</span>)</li>
</div>
<hr><br />"""
% tuple([item.choice, item.owner]))
self.response.out.write("""</ol>""")
self.response.out.write("""
</div>
</body>
</html>""")
Are you sure that chooser is undefined and not the string literal "undefined"?
see this fiddle i made

Validate one button is clicked before another with Javascript

This is in ASP.NET. We are using a ExtJS frontend, and have our own VB.NET controls to make all the Ext Forms and stuff. However, I hope this can be done in plain javascript. There is already some Javascript on the page for the 'Test Connection' button click and handling the result.
However, I need validation on the screen to make sure that a user tests the connection BEFORE saving the screen. (Hits the test button before hitting the save button) -- EACH time they visit the screen.
Here is the code for the page:
<%# Page Language="VB" Inherits="Core.Web.EditBaseView" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function testConnection() {
Global.mask('Testing Connection...');
KBBConnectorController.TestConnection(function(result) { testConnectionCallback(result) });
}
function testConnectionCallback(result) {
Global.unmask();
if (result.Data.Result) {
Global.alert("Connection to KBB Successful.");
}
else {
Global.alertError(result.Data.Messages[0].Text, result.Data.ExceptionId);
}
}
function Validate() {
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="display:none">
<% =Html.DropDownList("ddlMarketValues", TryCast(Model.MarketValues, SelectList))%>
</div>
<div>
<%
Using KBBForm As New WebControls.Forms.Form
With KBBForm
.OnValidate = "Validate"
.ID = "KBB"
.ItemName = "connector"
With .Toolbar
.UseDefaultButtons = False
.AddButton(Forms.FormToolbar.ButtonType.Save)
.AddButton(Forms.FormToolbar.ButtonType.Cancel)
.AddButton("Test Connection", "testConnection", "icon-button-testconnection", , "Test connectione")
End With
With .CenterRegion
.Id = "centerRegion"
With .AddFieldSet("Activate Service")
.Id = "activate"
.LabelWidth = 0
Dim cb As New Forms.Control("IsActive", "", "", Model.IsActive, Forms.Control.ControlType.CheckBox)
cb.BoxLabel = "Activate Service"
.AddControl(cb)
End With
With .AddFieldSet("Connection Parameters")
.Id = "params"
.LabelWidth = 150
.AddControl(New Forms.Control("UserName", "", "User Name", Model.UserName, Forms.Control.ControlType.TextField))
.AddControl(New Forms.Control("Password", "", "Password", Model.Password, Forms.Control.ControlType.Password))
.AddControl(New Forms.Control("LoginUrl", "", "URL", Model.LoginUrl))
With .AddControl(New Forms.Control("ddlMarketValues", "", "Market Value", , Forms.Control.ControlType.ComboBox))
.Id = "ddlMarketValues"
End With
End With
End With
Response.Write(.ToString)
End With
End Using
%>
</div>
</form>
</body>
</html>
As you can see I put an OnValidate function in there but it's blank, and you can see that it's tied to the Form as well. I tried fooling around with that but I could only put something together that would ask me to test every single time I clicked Save, and it wouldn't know if I already tested or not.
Any help? Thanks ahead of time.
-Scott
Uh, this should work if I did understand you correctly.
In the code which handles the result of the connection test, set a flag that indicates that the connection has been tested.
In the handler of the Save button check for that flag, and if it's not set display a message of some kind instead of actually performing the saving operation.
Your flag could be global variable which is initially set to false this way the user would be required to run the test each time the visit the page.
As on how you would override/intercept the Save buttons handler... uh... guess you'll have to extend the VB stuff for that.
Why not just hide the save button until the test connection is pressed and the connection works?

Categories

Resources