如果iPhone进入我的页面,我想更改div图层中的style.top位置。下面的代码(document.getElementById('footer')。style.top =“6550px”;)不起作用。当我插入window.location =“openingfriday1.htm”;进入相同的位置它工作正常。我究竟做错了什么?谢谢(感谢代码的'stackoverflow'用户)。
<script type="text/javascript">
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
} };
if ( isMobile.Android() ) {
window.location = "openingfriday1.htm";
}
else if(isMobile.iOS()) {
document.getElementById('footer').style.top = "6550px";
}
</script>