Android浏览器上的iframe javascript无法正常工作

时间:2019-04-19 06:02:58

标签: javascript android html5 geolocation

我尝试向用户请求位置许可,但是javascript窗口不起作用。

h5: function(func){
    if (navigator.geolocation) {
        if ("function" == typeof func) {
            h5LocationInit.fn = func
        }
        window.touchH5LocationCallback = function(f, g) {
            if(f == null){
                HN_Location.getLocationByGeocoding(g);
            }else{
                // getLocationError(f);
                HN_Location.init(func, true);
            }
            $("#touchH5LocationIframe").remove();
        },
            $('<iframe src="javascript:(function(){ window.navigator.geolocation.getCurrentPosition(function(position){parent && parent.touchH5LocationCallback && parent.touchH5LocationCallback(null,position);}, function(err){parent && parent.touchH5LocationCallback && parent.touchH5LocationCallback(err);}, {enableHighAccuracy: 1, maximumAge: 10000, timeout: 5000});})()" style="display:none;" id="touchH5LocationIframe" ></iframe>').appendTo("body")
    } else {
        Object.prototype.toString.call(func) && func.fn && func.fn(r)
        HN_Location.init(func, true);
    }
},

0 个答案:

没有答案