php跳轉到html頁面
① php如何實現頁面部分跳轉
PHP實現頁面跳轉的方式很多,可以使用header函數實現重定向,可以利用HTML Meta標簽功能,以及js等來實現。示例如下:
1.PHP header函數:
<?php
header("Content-type:text/html;charset=utf-8");
//示例跳轉網址$url="www.chinawinxp.com";
$url="
//重定向瀏覽器
header("Location:{$url}");
//退出
exit;
?>
2.使用HTML中Meta標簽實現跳轉,content:跳轉秒數(多少秒之後進行頁面跳轉);url:跳轉地址。
<html>
<head>
<metahttp-equiv="refresh"content="1;url=<?phpecho$url;?>">
</head>
<body>
頁面將在10秒後進行跳轉!!!
</body>
</html>
3.利用JS進行跳轉;
<?php
//示例跳轉網址$url="www.chinawinxp.com";
$url="
echo("<scriptlanguage='javascript'type='text/javascript'>");
//重定向
echo("window.location.href={$url}");
echo("</script>");
?>
② php 中如何實現跳轉到一個新的頁面
1、首先用HTTP頭信息重定向到另外一個頁面的方法,如下圖所示。
③ php怎麼跳轉到html頁面,並且向html傳遞數據急求解答
header("Location: http://www.xx.com?x=xx");
傳遞參數。後面直接加參數就好了啊。
④ php html登錄成功時,怎樣實現跳轉頁面
可以用以下方法
1) html的實現
<head>
<!-- 以下方式只是刷新不跳轉到其他頁面 -->
<meta http-equiv="refresh" content="10">
<!-- 以下方式定時轉到其他頁面 -->
<meta http-equiv="refresh" content="5;url=hello.html">
</head>
優點:簡單
缺點:Struts Tiles中無法使用
2) javascript的實現
<script language="javascript" type="text/javascript">
// 以下方式直接跳轉
window.location.href='hello.html';
// 以下方式定時跳轉
setTimeout("javascript:location.href='hello.html'", 5000);
</script>
優點:靈活,可以結合更多的其他功能
缺點:受到不同瀏覽器的影響
3) 結合了倒數的javascript實現(IE)
<span id="totalSecond">5</span>
<script language="javascript" type="text/javascript">
var second = totalSecond.innerText;
setInterval("redirect()", 1000);
function redirect(){
totalSecond.innerText=--second;
if(second<0) location.href='hello.html';
}
</script>
優點:更人性化
缺點:firefox不支持(firefox不支持span、div等的innerText屬性)
3') 結合了倒數的javascript實現(firefox)
<script language="javascript" type="text/javascript">
var second = document.getElementById('totalSecond').textContent;
setInterval("redirect()", 1000);
function redirect()
{
document.getElementById('totalSecond').textContent = --second;
if (second < 0) location.href = 'hello.html';
}
</script>
4) 解決Firefox不支持innerText的問題
<span id="totalSecond">5</span>
<script language="javascript" type="text/javascript">
if(navigator.appName.indexOf("Explorer") > -1){
document.getElementById('totalSecond').innerText = "my text innerText";
} else{
document.getElementById('totalSecond').textContent = "my text textContent";
}
</script>
5) 整合3)和3')
<span id="totalSecond">5</span>
<script language="javascript" type="text/javascript">
var second = document.getElementById('totalSecond').textContent;
if (navigator.appName.indexOf("Explorer") > -1) {
second = document.getElementById('totalSecond').innerText;
} else {
second = document.getElementById('totalSecond').textContent;
}
setInterval("redirect()", 1000);
function redirect() {
if (second < 0) {
location.href = 'hello.html';
} else {
if (navigator.appName.indexOf("Explorer") > -1) {
document.getElementById('totalSecond').innerText = second--;
} else {
document.getElementById('totalSecond').textContent = second--;
}
}
}
</script>
⑤ php點擊按鈕跳轉頁面
<inputtype="button"onclick="window.location.href='login.php'"value="點擊跳轉">
⑥ php跳轉html 通過onload方法傳參數的問題
js函數唄,window.onload=function(){
//這里的函數在頁面元素載入完成時候會自動調用
alert('成功');
}
你說的參數傳遞問題嗎,php傳遞參數給html頁面?那隻有在地址欄傳參數了
$url = 'www.xxx.com/sss.html?gram='.'$參數1';
header("Location:$url");
php傳參數給php頁面,要用到curl,你自己去網路吧,不能什麼我都告訴你
⑦ php頁面之間的跳轉可以傳遞ID,那php頁面跳轉不同的html頁面怎麼辦
您好,很高興回答您的問題,希望我的回答可以幫到您,謝謝。
如果您的html頁面是動態獲取數據,那麼你在點擊列表的時候把文章id傳到伺服器中,然後伺服器返回的數據渲染到html頁面,這樣就可以實現跳轉了
⑧ PHP頁面跳轉幾種實現方法
目前我知道兩種跳轉方式最常用,一種是form表單提交,一種是js中location.href跳轉