HTML:
<meta http-equiv="refresh" content="0;url=http://www.google.com" />
備註:0秒轉到google
Javascript:
<script>document.location.href="http://www.google.com";</script>
註1:如果要用_blank另開視窗的方式,可使用window.open('http://www.google.com')
註2:如果要用_parent父視窗開啟的方式,可使用parent.document.location.href="http://www.google.com"
註3:可使用相對網址
註4:也可以用 location = "http://www.google.com"; // JavaScript 大全(334頁)
參考:
細談 location.href 與 location.replace 的差別與實務應用
PHP:
header('Location: http://www.google.com');
備註:header之前不能有任何輸出(如echo)。
No comments:
Post a Comment