如何将值传递给函数

时间:2014-07-06 09:11:06

标签: javascript jquery

我试图将变量lat和lon添加到iframe网址。 javascript获取位置,然后我需要将其包含在iframe中。

如何引用lat和lon变量?

我已尝试this.latvicinity.lat

在我的javascript中我有

var Vicinity = function (pubReference, sessionId, done, err) {
this.ad = {
 getBannerHtml: function() {
  return '<iframe src="http://foo.com?pr=34&lat'+ this.lat+'=&lon=' + this.lon + '"></iframe>';
 }
 };

this.getLatLng = function(vicinity, done, err) {
 if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(done, function(e) {
  err(vicinity);
 }, { enableHighAccuracy:true } );
 } 
};

this.init = function(done, err) {
 var that = this;
 this.getLatLng(that, function(position) {
 that.lat = position.coords.latitude;
 that.lng = position.coords.longitude;
 }, err);
if(typeof done === 'function')
 done(this);
};

this.init(done, err);
};

$(document).ready(function() {
var pubReference = 1;
var sessionId = "1";
var data = new Vicinity (pubReference, sessionId, 
function(result) {
 $("#sticky").html(result.ad.getBannerHtml());
}
);
});

0 个答案:

没有答案