標題:
[網頁設計與CSS]
網頁自動轉址
[打印本頁]
作者:
gswdkimo
時間:
2011-9-28 10:37
標題:
網頁自動轉址
要自動轉址有幾種方法:
1. 用 body onload 的方法
< body>
2. 用 header meta 的方法 (建議)
< head>
< meta http-equiv="refresh" content="0;url=http://note.tcc.edu.tw">
< /head>
這種方法的好處是可以設定轉址秒數,例如設定每5分鐘重新 reload(轉址給自己)
< meta http-equiv="refresh" content="300">
或是5秒後轉址
< meta http-equiv="refresh" content="5;url=http://note.tcc.edu.tw">
3. 用 javascript 的方法
< head>
< script language="JavaScript">
location.href= ('http://note.tcc.edu.tw');
< /script>
< /head>
4. php 用 header 的方法:
< ?php
header("Location:
http://note.tcc.edu.tw/
");
?>
* 特別注意,除非萬不得已,不要輕易使用轉址,因為使用轉址會影響到 SEO。例如你使用的主機商預設只有 index.html,你要用 index.php;,而你又沒辦法修改 DocumentRoot ,只好使用轉址。
歡迎光臨 資訊家電班NO7 (http://imce07.freehostia.com/forums/)
Powered by Discuz! 7.2