PHP + HTML + JS:
<?php $url = "http://....."; ?>
<button name="redirect"onclick="redirectFunc(<?php echo $url; ?>);">Redirect with button</button>
<script>
function redirectFunc($url){
window.location.href = "<?php echo $url?>";
}
</script>
重定向HTML + PHP: http://www.w3schools.com/php/php_forms.asp
假設你的PHP文件位於地址: http://www.yourserver.com/form-action.php 在這種情況下,PHP_SELF將包含: 「/form-action.php」
<form method="post" action="<?php $_PHP_SELF ?>">
// type means what should button do submit -> submit your post
// name how you will recognize which post was sended
// value value of button which you can get
<button type="submit" name="redirect" value="redirectValue" id="redirect">Redirect with button post</button>
</form>
,然後你處理你的按鈕後點擊
<?php
if(isset($_POST['redirect'])) {
// rand your url
// echo $_POST['redirect']; will output redirectValue
header('Location: http://....');
}
?>
或者與AHREF: http://www.w3schools.com/html/html_links.asp
//or you can use ahref e.g
<?php $url = "http://...";
// code for randoming url
?>
<a href="<?php echo $url; ?>">Redirect with a href</a></p>
HTML + JS:
<button id="buttonID">redirect</button>
<script type="text/javascript">
// here you can rand your urls and choose one of them to redirect
document.getElementById("buttonID").onclick = function() {
location.href = "http://...";
};
</script>
做一個按鈕,然後當按鈕被點擊進入隨機頁面 –
你可以在Javascript中做一個表格,你根本就不 – Vuldo