我无法使用 JavaScript window.open 函数在 ipad 上打开弹出窗口, 这就是为什么我一直在尝试为 ipad 制定替代解决方案,灵感来自 this线程。
function newPopup(url) {
// Get the user agent string
var deviceAgent = navigator.userAgent;
// Set var to iOS device name or null
var ios = deviceAgent.toLowerCase().match(/(iphone|ipod|ipad)/);
if (ios) {
// This is the line that matters
$(this).attr('href', url);
}else{
popupWindow = window.open(
url,'popUpWindow','height=250,width=350,left=50,top=50,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no')
}
}
我仍然无法在 iPad 上打开新窗口。还有其他方法可以定位 ipad 吗?
最佳答案
是的,您可以在这里找到
if( navigator.platform === 'iPad' ){
alert('hurray');
}
更多详细信息请阅读此处: https://developer.mozilla.org/en-US/docs/Web/API/NavigatorID.platform
如果需要的话还可以检测 iPhone 和其他平台。
if( navigator.platform === 'iPhone' ){
alert('hurray');
}
关于iPad 上的 JavaScript 弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27164241/