Im trying to display an iframe on my page using javascript and html. I've messed up the javascript and need help returning the html from the javascript to the html.
It isn't working as nothing is being displayed. I dont think I'm calling the function correctly.
In my html I have:
<div id="sticky" class="banner-sticky" style="position: fixed;">
</div>
<script type="text/javascript">
var pubReference = 3;
var sessionId = "abcd123";
new Vicinity (pubReference, sessionId, function(result) {
$(function() {
$("#sticky").html(result.ad.getBannerHtml());
displayResults(result);
})
}, function(result) {
$("#sticky").html(result.ad.getBannerHtml());
$(function() {
displayResults(result);
})
});
</script>
and in my javascript I have:
var Vicinity = function(pubReference, sessionId, done, err) {
// defaults
this.pubReference = pubReference;
this.ad = {
getBannerHtml: function() {
return '<iframe src="http://ad.vic.co/banner?pr='+this.pubReference +'&lat'+ this.lat+'=&lon=' + this.lon + '"></iframe>'
}
};
this.getLatLng = function(vicinity, done, err) {
if (geoPosition.init()) { // Geolocation Initialisation
geoPosition.getCurrentPosition(done, function(e) {
console.warn('ERROR: ' + e.message);
err(vicinity);
}, { enableHighAccuracy:true } );
} else {
console.warn("Browser doesn't support Geolocation");
err(vicinity);
}
};
this.init = function(done, err) {
var that = this;
this.getLatLng(that, function(position) {
that.lat = position.coords.latitude;
that.lng = position.coords.longitude;
});
};
this.init(done, err);
};