Forum Moderators: open

Message Too Old, No Replies

controlling what loads in a frame with JS

         

pagey_3

11:27 am on Jun 20, 2005 (gmt 0)

10+ Year Member



I am building a site, and when skipping to active content it goes to a part of the site that is in a frameset. What i need to happen is, depending on which product you are signing up for for the appropriate page to load in the lower frame.

this is my frameset code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>M-Science SMS Server</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../styles/pc_ie.css" rel="stylesheet" type="text/css">
<frameset rows="235,*" cols="*" framespacing="0" frameborder="NO" border="0">
<frame src="header.html" name="topFrame" scrolling="no" noresize >
<frame src="signup.html" name="mainFrame" frameborder="no" marginwidth="0" marginheight="0">
</frameset><noframes></noframes>

</head>

<body align="center">
</body>
</html>

'signup.html is just a test page, but I want this frame to depend on where the user has just navigated from. What javascript shoul I use to do this? I have not used javascript much so if you could explain in simple terms I would really appreciate it!

Thanks in advance for any help!

Sathallrin

4:06 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



You could try doing something like:

<script language="javascript" type="text/javascript">
if(document.referer)
{
if(document.referer == "somepage"){
document.getElementByID("mainFrame").src="signup.html"
}
if(document.referer == "someotherpage"){
document.getElementByID("mainFrame").src="othersignup.html"
}
}
</script>

Then add ID's to your frames:

<frame src="header.html" id="topFrame" name="topFrame" scrolling="no" noresize >
<frame src="" id="mainFrame" name="mainFrame" frameborder="no" marginwidth="0" marginheight="0">

This would not work so well, as it depends on the referer existing. Your best bet would be to use PHP or some other server side scripting language, and pass in the page you want displayed as a variable.

Sathallrin

4:47 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



You could also pass in the query string (like I mentioned above), and then parse it with javascript... If you can't use server side scripted pages.

pagey_3

3:24 pm on Jun 28, 2005 (gmt 0)

10+ Year Member



Just to let you know this is what I was looking for - thanks for your advice though - hope this can help someone else too :-)

[quirksmode.org ]