我有一個非常基本的框架佈局:index.html的元刷新與框架目標
<frameset rows="80,*" frameborder="1" border="5" framespacing="0">
<frame name="topNav" src="top_nav.html">
<frameset cols="220,*" frameborder="1" border="5" framespacing="0">
<frame name="menu" src="menu_1.php" marginheight="0" marginwidth="0" scrolling="auto" noresize>
<frame name="content" src="content.php" marginheight="0" marginwidth="0" scrolling="auto" noresize>
</frameset>
</frameset>
和檢查,如果用戶名和密碼匹配數據庫等簡單的登錄腳本
現在我希望它做的是,如果信息是正確的,是自動重定向的菜單欄,但所有我能做的就是重定向的內容部分
// check to see if they match!
if ($username==$dbusername&&$password==$dbpassoword)
{
$_SESSION['username']=$username;
echo '<meta http-equiv="REFRESH" content="2 ; url=servers.php" target="menu">';
}
else
echo "<center>Incorrect Information!</center>" ;
現在,我可以很容易地做到這一點,如果我讓用戶點擊一個<a href>
標籤
E.G. <a href="servers.php" target="menu">click me</a>
所以我想我可以簡單地把target="menu"
放在我的meta
標籤中,但是它所做的只是重定向內容頁面。
所以我的問題是,我做錯了什麼,或者有一個更簡單的方法來做到這一點?
它已經永遠自我見過一個網站上使用的框架...或元刷新此事。如果您已經在使用PHP,那麼爲什麼不將這些部分包含到您的顯示中 - 而不是創建框架......然後,您可以在成功登錄後執行標題('Location:something')。 如果你想堅持使用框架,我會使用JavaScript來強制重新加載元標記。 document.getElementById('menu')。location =「something」,也許? – Applehat 2013-03-01 20:49:00
你好applehat,如果我是誠實的,我不是幀的大粉絲,但我想現在給它一段時間,所以我做了一個小項目,爲我自己,並已學會了許多事情辦法。但是,將來我會使用CSS,因爲它看起來更可靠。並感謝您的回答,它也工作:) – 2013-03-01 20:57:02
沒問題!是啊。框架集和元刷新是網絡世界中真正的老技術。關於唯一的「可接受的」框架不再是iFrame ......甚至應該謹慎使用它們。 JavaScript讓你現在可以做得更乾淨=) – Applehat 2013-03-01 21:03:00