问题
I have a very basic frame layout: 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>
And a simple login script which checks if the username and password match the database and so on
Now what i want it to do is if the information is correct, is to auto redirect the menu bar, but all i can do is redirect the content section
// 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>" ;
Now i can easily do it if i get the user to click on an <a href>
tag
E.G. <a href="servers.php" target="menu">click me</a>
So i thought i could simply put the target="menu"
in my meta
tags, but all it does is redirect the content page.
So my question is, am i doing something wrong, or is there a simpler way to do this?
回答1:
I believe you can't do it with headers. You could output regular javascript along your content. Something like this:
<script>
parent.menu.location.href = "/some-url";
</script>
回答2:
Give you frame (menu) an id: Then change the code like this:
Change
echo '<meta http-equiv="REFRESH" content="2 ; url=servers.php" target="menu">';
To
echo '<script>var iframe = document.getElementById("youriframe");iframe.src="servers.php";</script>';
来源:https://stackoverflow.com/questions/15166507/meta-refresh-with-a-frame-target