 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
HaLo2FrEeEk
Joined: 03 Dec 2006 Posts: 2
|
Posted: Sun Dec 03, 2006 6:37 pm A little question about a simple switch statement |
|
|
|
I am trying to write a simple switch statement that will call up a javascript located on the page, to load a different page into an iframe depending on a variable in the URL, The code I am using is:
| Code: |
<?php
$view="home";
switch ($_GET["view"]) {
case "home":
echo "<script type=\"javascript\"><!--";
echo "fasttravel('pages/home.html','Home');";
echo "// --></script>";
break;
case "roster":
echo "<script type=\"text/javascript\"><!--";
echo "fasttravel('pages/roster.html','Roster');";
echo "// --></script>";
break;
}
?>
|
Where fasttravel() is the javascript I want to call up, this javascript function is very simple:
| Code: |
function fasttravel(url,title){
maincontent.location=url;
document.title="Clan Infectionist :: "+title;
}
|
Something is wrong though and I can't get it to go to the roster, this is only a test of the code, there are 6 different pages I want it to be able to load: home, roster, affiliates, projects, movies, and music, right now, to get to these pages, people have to go to the main page, then click the respective link to load the, for example, roster, into the iframe, I want them to be able to type: http://claninfectionist.com/?view=roster and it will take them there automatically using the javascript, but for whatever reason, its not reading the variable from the url, it always defaults back to home if the ?view= is in the url, what can I do?
Thanks in advance.
~HaLo2FrEeEk |
|
degsy

Joined: 23 Feb 2005 Posts: 2440 Location: North East, UK
|
Posted: Fri Dec 08, 2006 6:51 am |
|
|
|
Why are you using javascript at all when you can use PHP to set the src of the iframe?
You problem is because you are calling the script before the iframe has been created.
Change your script to ouput an onload event instead. |
|
HaLo2FrEeEk
Joined: 03 Dec 2006 Posts: 2
|
Posted: Sun Dec 10, 2006 11:23 pm |
|
|
|
| I could use all php, but my knowledge of php, and thusly, creativity with it, is about this: |_|, yeah, anywho, I figured out how to do it with javascript, just did a substr with a switch statement to find anything after the view=, so basically, someone can go to http://claninfectionist.com/?view=roster and it will take them to the frontpage, but will load the roster in the frame, its crude, but it works, for now. |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|