幾種網頁轉址的語法

HTML

<head>
<meta http-equiv=refresh content="0;url=http://host.domain.tld/path/to/">
</head>

JavaScript

<script language="JavaScript">
<!--
  window.location.href = "http://host.domain.tld/path/to/";
//-->
</script>

PHP

<?php
  header("Location: http://host.domain.tld/path/to/");
?>

(轉址前不可有任何資料輸出)

Perl

#!/usr/bin/perl -w
print "Location: http://host.domain.tld/path/to/ \n\n";

(轉址前不可有任何資料輸出)

Perl – 使用 CGI 模組

#!/usr/bin/perl -w
use CGI qw/:standard/;
my $CGI = CGI->new();
print $CGI->redirect("http://host.domain.tld/path/to/");

(轉址前不可有任何資料輸出)

您可能會對以下這些文章感興趣

本篇發表於 coding, javascript, perl, php 並標籤為 , , , 。將永久鍊結加入書籤。

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*

您可以使用這些 HTML 標籤與屬性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>