元刷新和重定向页面? [英] Meta refresh and redirect a page?

查看:111
本文介绍了元刷新和重定向页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < META http-equiv =refresh内容

我创建了一个META标记的网页,就像这样:

= 5; URL = HTTP://www.google.com >

问题是移动浏览器不支持这个元标记,虽然它在web上正确重定向每一个浏览器。



完整的网页代码在这里:

 < ; HTML> 
< head>
< META http-equiv =refreshcontent =5; URL = http://www.google.com>
< script>

var URL =mziiki:// app;
var MARKET =market:// details?id = com.spice.mziiki;
var APPLEMARKET =https://itunes.apple.com/in/app/mziiki/id875256574?ls=1&mt=8;
var PLAYSTORE =https://play.google.com/store/apps/details?id=com.spice.mziiki;
var ITUNES =mziiki:// app;

函数onLoad(){

if(navigator.userAgent.match(/ Android /)){

if(navigator.userAgent.match (/ Chrome /)){

window.location =intent:// app#Intent; package = com.spice.mziiki; scheme = mziiki; end;;

} else {

//旧版Android浏览器
var iframe = document.createElement(iframe);
iframe.style.border =none;
iframe.style.width =1px;
iframe.style.height =1px;
var t = setTimeout(function(){
window.location = MARKET;
},1000);
iframe.onload = function(){clearTimeout(call)};
iframe.src = URL;
document.body.appendChild(iframe);


$ b} else if(navigator.userAgent.match(/ iPhone | iPad | iPod /)){
// IOS
setTimeout(函数(){
if(!document.webkitHidden)
window.location = APPLEMARKET;
},25);

window.location = ITUNES;

} else {

//不移动
window.location = PLAYSTORE;
}
}
< / script>
< / head>
< body onload =onLoad()>
< / body>
< / html>

这是怎么回事?我无法找到解决方案,移动浏览器也会自己制定规则吗?

任何人都有类似的问题?

解决方案

我建议您使用PHP重定向到网页...用户无法更改HEADER,PHP中的代码是:

 <?php header(Location:dir / file.php); ?> 

将其插入页面顶部的代码中...



哦,我没有看到等待的时间,在PHP中,您可以这样做:

 <?php header(refresh:5; url = page.php); ?> 

在刷新处写入等待的秒数

I creates a webpage with a META tag exactly like this :

<META http-equiv="refresh" content="5;URL=http://www.google.com">

The problem is that mobile browsers does not support this meta tag, although it does redirect properly in web on every browser.

full code of webpage is here :

<html>
  <head>
    <META http-equiv="refresh" content="5;URL=http://www.google.com">
<script>

var URL = "mziiki://app";
var MARKET = "market://details?id=com.spice.mziiki";
var APPLEMARKET = "https://itunes.apple.com/in/app/mziiki/id875256574?ls=1&mt=8";
var PLAYSTORE = "https://play.google.com/store/apps/details?id=com.spice.mziiki";
var ITUNES = "mziiki://app";

function onLoad() {

    if (navigator.userAgent.match(/Android/)) {

        if (navigator.userAgent.match(/Chrome/)) {

             window.location = "intent://app#Intent;package=com.spice.mziiki;scheme=mziiki;end;";

        } else {

            // Older Android browser
            var iframe = document.createElement("iframe");
            iframe.style.border = "none";
            iframe.style.width = "1px";
            iframe.style.height = "1px";
            var t = setTimeout(function() {
                window.location = MARKET;
            }, 1000);
            iframe.onload = function () { clearTimeout(call) };
            iframe.src = URL;
            document.body.appendChild(iframe);

        }

     } else if (navigator.userAgent.match(/iPhone|iPad|iPod/)) {
         // IOS
         setTimeout(function() {
             if (!document.webkitHidden)
                 window.location = APPLEMARKET;
         }, 25);

         window.location = ITUNES;

     } else {

         // Not mobile
         window.location = PLAYSTORE;
     }
}
</script>
  </head>
  <body onload="onLoad()">
  </body>
</html>

What's going on here? I can't find a solution, so does mobile browsers make up it's own rules ?

Anyone have a similar problem ?

解决方案

I suggest you use PHP for redirect to a webpage... The user can't change the HEADER, the code in PHP is:

<?php header("Location: dir/file.php") ; ?>

Insert it in your code on top of the page...

Oh, i don't see the time to wait, in PHP you can do like this:

<?php  header( "refresh:5;url=page.php" ); ?>

Where in Refresh you write the seconds to wait

这篇关于元刷新和重定向页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆