页面强制跳转&PC跳转到手机WAP&iframe完美嵌套无白边

页面跳转方式一:

<meta http-equiv="refresh" content="0; url=http://qinbinjie.lofter.com/">

页面跳转方式二:

<script language='javascript'>document.location = 'http://www.kaigesheji.com/wangzhanjianshe/ '</script>

手机浏览PC自动跳转至WAP一:这里引用的是搜狐快站的代码

<link rel="alternate" type="application/vnd.wap.xhtml+xml" media="handheld" href="http://cqmall.kuaizhan.com/"/>
<script src="http://kzcdn.itc.cn/res/skin/js/uaredirect.js?v=4.9" type="text/javascript"></script>
<script type="text/javascript">KZ.redirect("http://m.cqzjia.com/");</script>

手机浏览PC自动跳转至WAP二:

<script LANGUAGE="JavaScript">
 function mobile_device_detect(url)
 {
        var thisOS=navigator.platform;
        var os=new Array("iPhone","iPod","iPad","android","Nokia","SymbianOS","Symbian","Windows Phone","Phone","Linux armv71","MAUI","UNTRUSTED/1.0","Windows CE","BlackBerry","IEMobile");
 for(var i=0;i<os.length;i++)
        {
 if(thisOS.match(os[i]))
        {  
  window.location=url;
 }
          
 }
 //因为相当部分的手机系统不知道信息,这里是做临时性特殊辨认
 if(navigator.platform.indexOf('iPad') != -1)
        {
  window.location=url;
 }
 //做这一部分是因为Android手机的内核也是Linux
 //但是navigator.platform显示信息不尽相同情况繁多,因此从浏览器下手,即用navigator.appVersion信息做判断
  var check = navigator.appVersion;
  if( check.match(/linux/i) )
          {
   //X11是UC浏览器的平台 ,如果有其他特殊浏览器也可以附加上条件
   if(check.match(/mobile/i) || check.match(/X11/i))
                 {
   window.location=url;
   } 
 }
 //类in_array函数
 Array.prototype.in_array = function(e)
 {
  for(i=0;i<this.length;i++)
  {
   if(this[i] == e)
   return true;
  }
  return false;
 }
 }
mobile_device_detect("http://qinbinjie.lofter.com/");
</script>

iframe完美嵌套无白边:

    <div class="ifr" onMouseOut="hideS()" onMouseOver="showS()" style="    width: 100%;    height: 100%;">
    <iframe id="test" width="100%" height="100%" frameborder="0" src="http://qinbinjie.lofter.com/" style="margin:0px;" ></iframe>
    <script language="JavaScript">  
            var iframe = document.getElementById("test");   
            iframe.src = "http://qinbinjie.lofter.com/"; 
            //以下判断iframe是否加载完,并且隐藏滚动条
            if (iframe.attachEvent){
                iframe.attachEvent("onload", function(){                                
                    //hideS();
                    //document.getElementById("loading").style.display="none";  
                });   
            } else {   
                iframe.onload = function(){
                //   hideS();                    
                //document.getElementById("loading").style.display="none";  
                };   
            }
        </script> 
    </div>

三者都需要集成HTML:

<html>
<head>
	<!-- HTML meta refresh URL redirection -->
	<!--<meta http-equiv="refresh" content="0; url=http://qinbinjie.lofter.com/">  PC页面跳转代码-->
	<!--手机页面跳转开始
	<link rel="alternate" type="application/vnd.wap.xhtml+xml" media="handheld" href="http://cqmall.kuaizhan.com/"/>
	<script src="http://kzcdn.itc.cn/res/skin/js/uaredirect.js?v=4.9" type="text/javascript"></script>
	<script type="text/javascript">KZ.redirect("http://m.cqzjia.com/");</script>
	-->
<meta charset="UTF-8">
<link rel="shortcut icon" href="http://imgsize.ph.126.net/?imgurl=http://img0.ph.126.net/H1G7tQuySMENTjpEypsSGw==/6630594975700025052.jpg_16x16x0x90.jpg" />
<title>秦彬杰的轻博客,从产品经理到产品大师</title>
<meta name="keywords" content="产品经理,人人都是产品经理,PRD,axure,axure教程,产品经理培训,产品经理招聘,交互设计,产品需求文档,产品设计,原型设计,demo,app,产品运营,互联网,移动互联网,互联网创业,产品经理论坛" />
<meta name="description" content="秦彬杰产品设计案例集合,建议用火狐浏览器打开!我的博客:www.cqzjia.com" />

<script type="text/javascript">
  function showS()
  {
    document.getElementById("test").scrolling="yes";
    document.getElementById("test").style.overflow="scroll";
    //alert(document.getElementById("test").scrolling);
     
  }
  function hideS()
  {
    document.getElementById("test").scrolling="no";
    document.getElementById("test").style.overflow="hidden";
    //alert(document.getElementById("test").style.overflow);
  }
</script>    

<--跳转到手机页面-->
<script LANGUAGE="JavaScript">
 function mobile_device_detect(url)
 {
        var thisOS=navigator.platform;
        var os=new Array("iPhone","iPod","iPad","android","Nokia","SymbianOS","Symbian","Windows Phone","Phone","Linux armv71","MAUI","UNTRUSTED/1.0","Windows CE","BlackBerry","IEMobile");
 for(var i=0;i<os.length;i++)
        {
 if(thisOS.match(os[i]))
        {  
  window.location=url;
 }
          
 }
 //因为相当部分的手机系统不知道信息,这里是做临时性特殊辨认
 if(navigator.platform.indexOf('iPad') != -1)
        {
  window.location=url;
 }
 //做这一部分是因为Android手机的内核也是Linux
 //但是navigator.platform显示信息不尽相同情况繁多,因此从浏览器下手,即用navigator.appVersion信息做判断
  var check = navigator.appVersion;
  if( check.match(/linux/i) )
          {
   //X11是UC浏览器的平台 ,如果有其他特殊浏览器也可以附加上条件
   if(check.match(/mobile/i) || check.match(/X11/i))
                 {
   window.location=url;
   } 
 }
 //类in_array函数
 Array.prototype.in_array = function(e)
 {
  for(i=0;i<this.length;i++)
  {
   if(this[i] == e)
   return true;
  }
  return false;
 }
 }
mobile_device_detect("http://qinbinjie.lofter.com/");
</script>

<style>
<!-- .ifr{width:600px;height:600px;background:#fff;overflow:hidden;display:block;position:absolute;top: 0;left: 0;right: 0;} -->
</style>
</head>
<body>
    <div class="ifr" onMouseOut="hideS()" onMouseOver="showS()" style="    width: 100%;    height: 100%;">
        <iframe id="test" width="100%" height="100%" frameborder="0" src="http://qinbinjie.lofter.com/" style="margin:0px;" ></iframe>
        <script language="JavaScript">  
            var iframe = document.getElementById("test");   
            iframe.src = "http://qinbinjie.lofter.com/"; 
            //以下判断iframe是否加载完,并且隐藏滚动条
            if (iframe.attachEvent){
                iframe.attachEvent("onload", function(){                                
                    //hideS();
                    //document.getElementById("loading").style.display="none";  
                });   
            } else {   
                iframe.onload = function(){
                //   hideS();                    
                //document.getElementById("loading").style.display="none";  
                };   
            }
        </script> 
    </div>
</body>
</html>

阅读更多
版权声明:©秦彬杰(花无缺)/ www.cqzjia.com https://blog.csdn.net/SentimentalVersion/article/details/79954238
文章标签: JS WAP 页面跳转
个人分类: 代码的片段
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭