简体   繁体   English

身体标签内的HTML重定向?

[英]HTML redirect within body tags?

Is there a method that gives the same result as the meta redirect that can be used in the body of an html doc? 是否有一种方法可以提供与可以在html doc正文中使用的元重定向相同的结果? Or a reference in the body to CSS? 或者身体对CSS的引用? I've been searching but the only things I can find want to make use of other technologies. 我一直在寻找,但我能找到的唯一的东西想要利用其他技术。

NB this is for an iOS UIWebView so no php and I'd rather not load any extra js. 注意这是一个iOS UIWebView所以没有PHP,我宁愿不加载任何额外的js。

If you can use Javascript, something like this should help you: 如果你可以使用Javascript,这样的东西可以帮助你:

<script type="text/javascript">
    window.location = "http://www.google.com/";
</script>

Check this link to see how to place that inside a function that can be called with "onclick" or "on body load" , etc... 检查此链接以查看如何将其放置在可以使用“onclick”“on body load”等调用的函数中...

http://www.tizag.com/javascriptT/javascriptredirect.php http://www.tizag.com/javascriptT/javascriptredirect.php


EDITED: 编辑:

Another good thing to read about this: 关于此的另一个好处:

https://developer.mozilla.org/en/window.location https://developer.mozilla.org/en/window.location

I would use both meta and js redirects, also you may be interested on SEO by using rel="canonical" : 我会使用meta和js重定向,你也可能对SEO感兴趣使用rel =“canonical”

<html>
<head>
    <link rel="canonical" href="http://stackoverflow.com/"/>        
    <script type="text/javascript">            
        window.location.replace("http://stackoverflow.com"); 
    </script>
    <title>Redirection</title>
</head>
<body>
    <noscript>
        <meta http-equiv="refresh" content="0;URL=https://stackoverflow.com/">
    </noscript>
    If you are not redirected automatically, follow the <a href='https://stackoverflow.com'>link </a>
</body>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM