[英]Skipping over javascript content on iPad/iPhone
I have the following code working, but I would like to just skip it altogether if the user is on an iPad or iPhone. 我可以使用以下代码,但是如果用户使用的是iPad或iPhone,我想完全跳过它。 How do I go about doing that? 我该怎么做?
<script>
var elements = ['<video autoplay="true" width="900" height="540" id="myVideo">',
'<source src="/s/phlogo.mp4" type="video/mp4">',
'<source src="/s/phlogo.ogg" type="video/ogg">',
'<source src="/s/phlogo.webm" type="video/webm">',
'</video>'].join('\n');
</script>
<script>
jQuery(document).ready(function ($) {
$.fancybox.open({
padding: 0,
content: elements,
type: "html"
});
$("#myVideo").on("ended", function () {
$.fancybox.close();
});
}); // ready
</script>
Thanks for any help! 谢谢你的帮助!
Depends if you're using jQuery or not. 取决于您是否使用jQuery。
JS: JS:
if (/iPhone|iPad/i.test(navigator.userAgent)) { //code };
jQuery( not recommended ): jQuery( 不推荐 ):
<script>
$.browser.device = (/iPhone/iPad/i.test(navigator.userAgent.toLowerCase()));
if ($.browser.device == true) {
jQuery(document).ready(function ($) {
$.fancybox.open({
padding: 0,
content: elements,
type: "html"
});
$("#myVideo").on("ended", function () {
$.fancybox.close();
});
}); // ready
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.