Meta refresh and redirect a page?

2019-05-31 06:29发布

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 ?

1条回答
冷血范
2楼-- · 2019-05-31 06:52

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

查看更多
登录 后发表回答