我想在agent == iphone& amp;时更改fancybox的rel属性ipod因为 fancybox无法在iphone上运行。框架非常小,视频无法观看。我在类别页面上使用带有magento的fancybox。
当iphone上的用户点击“点击我”时,视频应该在正常的YouTube页面上打开,否则(在计算机上)fancybox应该正常显示。
我尝试了以下代码,但它不起作用。
还有其他解决方案。
答案 0 :(得分:0)
从您的代码中,如果agentID
不 iPhone/iPod
,您为什么不尝试初始化fancybox?
...类似于:
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod)/);
jQuery(document).ready(function () {
// only initialize fancybox if agentID IS NOT iPhone/iPod
if (!agentID) {
jQuery("a[rel=fancybox]").fancybox({
// API options
})
}
});