几种页面重定向代码

方法一:对于HTML语言

以下是代码片段: <html> <head> <meta http-equiv=”Refresh” content=”2;url=http://www.你的域名.com”> </head> <body> Loading… </body> </html>

对于HTML语言可以用如上方法,

以上含义为:则会在2秒之后重定向到 http://www.你的域名.com;如果 http://www.你的域名.com为本身,则每2秒自动刷新1次;如果 content=0,则立即重定向。

方法二:对于ASP语言

以下是代码片段: <%Response.Redirect “http://www.你的域名.com “%>

以上代码为立即转向到http://www.你的域名.com

方法三:对于ASP.NET

以下是代码片段: <script runat=”server”> private void Page_Load(object sender, System.EventArgs e) { Response.Status = “301 Moved Permanently”; Response.AddHeader(“Location”,”http://www.你的域名.com”); } </script>

和方法二含义一样

方法四:js实现

以下是代码片段: <script language=”javascript”> url = window.location.href; url = url.replace(“http://www.你的域名.com”,”http://你的域名.com”);//把网址代换 window.navigate(url); </script>

方法五:PHP页面

以下是代码片段: <? Header( “Location: http://www.你的域名.com” ); ?>

未经允许不得转载:哈勃私语 » 几种页面重定向代码

本文共757个字 创建时间:2016年10月5日10:43   

分享到:更多 ()