PDA

View Full Version : Complicated redirect using frameset - Possible?


sburns1992
11-03-2010, 06:46 PM
Hey,
I have a vBulletin forum, I also have a radio player... I have put the radio player and the forum into a frameset so that the radio doesn't stop and start everytime the page changes. The code for the index.html looks like this:
<frameset framespacing="0" border="0" frameborder="0" rows="0,*">
<frame id="radio" name="radio" scrolling="no" noresize target="main" src="radio/play.php" marginwidth="0" marginheight="0">
<frame id="main" name="main" src="index.php">
<noframes>
<body>

<p>This page uses frames, but your browser doesn't support them.</p>

</body>
</noframes>
</frameset>
With index.php being the forum & the radio/play.php being the radio player

The only problem with this is, when someone wants to link to a thread to the forum, it will load the forum without the frameset meaning the radio won't play.
If there a way, that when a link to the forum is clicked it will redirect to the index.html page and then open the clicked link in the main frame, so that the radio will then play and show the linked thread in the main frame?

I think that makes sence

Thanks,
Scott :)

sburns1992
11-05-2010, 05:33 PM
Can anyone help at all?

kh99
11-05-2010, 10:40 PM
Well, you could make your index.php something like this:


<?php
$page = $_REQUEST["page"];
if (empty($page))
$page = "forums.php"; // or whatever your home page is...
?>
<frameset framespacing="0" border="0" frameborder="0" rows="0,*">
<frame id="radio" name="radio" scrolling="no" noresize target="main" src="radio/play.php" marginwidth="0" marginheight="0">
<frame id="main" name="main" src="<?php echo $page ?>">
<noframes>
<body>

<p>This page uses frames, but your browser doesn't support them.</p>

</body>
</noframes>
</frameset>


and then in a page you could have something like



<script type="text/javascript">
function loadframes()
{
var page = document.location.href;
page = page.substring(page.lastIndexOf('/') + 1, page.length) ;
document.location.href = "index.php?page=" + encodeURI(page);
}
</script>
...
<BODY onload="if (self==top) loadframes();">



And it would load itself in to the frames. The problem is that I don't know how you'd get that in to every page, and what you'd do if a page already had an "onload" attribute.

ETA: Maybe you could have a "start radio" link or button instead of having it load automatically? That might be easier to add to every page.