0

2 番目の更新: Safari の修正がなく、他のいくつかの奇妙な動作があるため、この選択を使用して Safari ユーザー向けのすべての新しい退屈なコンテンツを作成することにしました (基本的に Safari のスクリプト作成はあきらめました)...

<?php if($detect->version('Safari')) {  ?>
$(function() {
    /* create second option because Safari sucks? */
    $("#gotorep").remove();
    $("#entersite").remove();
    $("#entersite2").css({'display':'inline'});
});
<?php } elseif($detect->isMobile()) {  ?>
   function startfunc() {
      if(navigator.geolocation) {
.
.
.

エラーの更新 (これは修正され、削除されました): Safari での私のエラーは 35772ReferenceError: 変数が見つかりません: この場所で失敗します...

 $(function() {
    if(navigator && navigator.geolocation) {
        var fallback = setTimeout(function() { fail('10 seconds expired'); }, 10000);
***http://devv.referadiabetic.com/:35772ReferenceError: Can't find variable: fail
        navigator.geolocation.getCurrentPosition(
                function (pos) {
                    clearTimeout(fallback);

元の質問: Safari 以外の他のモバイル デバイス/ブラウザーでこれを動作させることができます。iPhone では失敗したので、if の選択を ! で逆にしました。同じ問題を抱えた Safari デスクトップ ブラウザーでテストしましたが、同意するとデータが返されませんでした。これは私が今取り組んでいるコードのブロックです...

<?php if(!($detect->isMobile())) {  ?>
$(function() {
    if(navigator && navigator.geolocation) {
        var fallback = setTimeout(function() { fail('10 seconds expired'); }, 10000);
        navigator.geolocation.getCurrentPosition(
                function (pos) {
                    clearTimeout(fallback);
                    var point = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
                    new google.maps.Geocoder().geocode({'latLng': point}, function (res, status) {
                        if(status == google.maps.GeocoderStatus.OK && typeof res[0] !== 'undefined') {
                            var zip = res[0].formatted_address.match(/,\s\w{2}\s(\d{5})/);
                            if(zip) {
                                var zipcodepassed = zip[1];
                                $("#em").html(zipcodepassed);
                                var reps = reps_load;
                                var ads_repList_URLtoFullName = ads_repList_URLtoFullName_load;
                                var rek = ads_repList_URLtoFullName;
                                var rep = reps[zipcodepassed];
                                    if (rep == undefined || rep == null || rep == "") {
                                            $(function() {
                                                $("#gotorep").remove();
                                                $("#entersite").remove();
                                                $("#entersite2").css({'display':'inline'});
                                            });
                                    }
                                var repname = rek[rep]; //i.e. shaner will be Shane Reaume in repname variable
                                $("#yourrep").html(repname);
                                $("a[href='http://devv.referadiabetic.com']").attr('href', 'http://devv.referadiabetic.com/' + rep);
                            }
                        }
                    });

                }
        );

    }
});

私はすでにこれをフォールバックとして持っています。IP アドレスを使用して郵便番号を取得していますが、モバイル デバイスの性質上、このコード ブロックを実行するように設定しています。

4

1 に答える 1

1

setTimeout最初のパラメーターは、何らかのコードの文字列または関数の呼び出しであると想定しています。文字列として解析しようとしていると思いますがfail、... うーん... 失敗しています。

setTimeout("function() fail('10 seconds expired');", 10000);
于 2012-12-20T17:08:08.187 に答える