2016-12-24 65 views
-3

這是錯誤的補丁:我該如何解決無效的正則表達式?

enter image description here

這裏是在iPhone設備我的隱藏模式代碼

$(document).ready(function(){ 
    var modal = $('.myModal', window.top.document); // Works 
    modal.on('show.bs.modal', function(e) { 
     var width = $(window).width(); 
     var testdevice = /iPhone/i.test(navigator.userAgent); 
     if(testdevice) { 
     $(this).modal('toggle'); 
     } 
    }); 
    }); 
+0

嗨..你正在嘗試要使用這個正則表達式 – Shibon

+0

我想在iPhone設備中隱藏模式。 @Shibon –

+0

嗨請看這個鏈接他們已經完成 http://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-mobile-device-in-jquery – Shibon

回答

0

嘗試這樣

$(document).ready(function(){ 
var modal = $('.myModal', window.top.document); // Works 
modal.on('show.bs.modal', function(e) { 
    var width = $(window).width(); 
    if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 
    $(this).modal('toggle'); 
    } 
}); 
});