中央論壇 - CENTER BBS
標題:
網頁自動轉址/導向頁面 - 三種轉址方法教學 (HTML/JS/PHP)
[打印本頁]
作者:
死神
時間:
2014-3-23 11:48
標題:
網頁自動轉址/導向頁面 - 三種轉址方法教學 (HTML/JS/PHP)
1. HTML 的轉址方法:
在 HTML 網頁的 <head> 中加入以下 HMTL 碼,網頁就會自動轉址。
<meta http-equiv="refresh" content="0;url=http://www.centerbbs.com" />
複製代碼
其中 content=""中的 0 是指 0 秒後自動重新整理,並轉址到 "http://www.centerbbs.com" 這個 URL。
2. Javascript 的轉址方法:
在 HTML 網頁中原則上是任一地方加入以下 JavaScript 網頁就會轉址。但放在網頁 HTML 碼的開始較有效率(也較有意義)。
<script>document.location.href="http://www.centerbbs.com";</script>
複製代碼
簡短寫法(不宣告document):
<script>location.href="http://www.centerbbs.com";</script>
複製代碼
3. PHP 的轉址方法:
<?php
header('Location: [url]http://www.centerbbs.com[/url]');
exit;
?>
複製代碼
作者:
死神
時間:
2014-3-23 11:51
HTML轉址頁懶人包:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="refresh" content="0;url=http://www.centerbbs.com">
<title>轉址網頁</title>
</head>
<body>
</body>
</html>
複製代碼
歡迎光臨 中央論壇 - CENTER BBS (https://www.centerbbs.com/)
Powered by Discuz! X3