dynamic write of frameset

A

Alain Bourgeois

Dear all,


I'm new to javaScript. I would like to know why this code does not work:

<html>
<head></head>

<frameset cols="200,*" frameborder="1">
<frame name="contents" src="menu.htm">
<script language="JavaScript1.1" type="text/javascript">
document.write("<frame name=\"prod\" src=\"prod01.htm\">");
</script>
</frameset>

</html>


I would like to pass a parameter to the html page (in url) which would
tell me which html src to use in the "prod" frame, but scripts doesn't
seem to run (nor to be run) in frameset section.

(http://prod01site.com would be redirected to
http://myglobalsite.com/index.html?product="prod1.htm", and would load
prod1.htm into "prod" frame).

Is there a way to do this?


Regards,
Alain
 
D

Darko

Dear all,

I'm new to javaScript. I would like to know why this code does not work:

<html>
<head></head>

<frameset cols="200,*" frameborder="1">
<frame name="contents" src="menu.htm">
<script language="JavaScript1.1" type="text/javascript">
document.write("<frame name=\"prod\" src=\"prod01.htm\">");
</script>
</frameset>

</html>

I would like to pass a parameter to the html page (in url) which would
tell me which html src to use in the "prod" frame, but scripts doesn't
seem to run (nor to be run) in frameset section.

(http://prod01site.comwould be redirected tohttp://myglobalsite.com/index.html?product="prod1.htm", and would load
prod1.htm into "prod" frame).

Is there a way to do this?

Regards,
Alain

Seems that there is not. See HTML standard. For an example, BODY tag
definition says:

<!ELEMENT BODY O O (%block;|SCRIPT)+ +(INS|DEL) -- document body -->

where %block may be any of the block elements (div, table, paragraph,
etc.), and as you see SCRIPT is
allowed as well. Now let's take a look at the FRAMESET definition:

<!ELEMENT FRAMESET - - ((FRAMESET|FRAME)+ & NOFRAMES?) -- window
subdivision-->

Only inner framesets, frames and noframes' are allowed. No mention of
SCRIPT.

Sorry
 
P

pr

Alain said:
I'm new to javaScript. I would like to know why this code does not work:

<html>
<head></head>

<frameset cols="200,*" frameborder="1">
<frame name="contents" src="menu.htm">
<script language="JavaScript1.1" type="text/javascript">
document.write("<frame name=\"prod\" src=\"prod01.htm\">");
</script>
</frameset>

</html>


I would like to pass a parameter to the html page (in url) which would
tell me which html src to use in the "prod" frame, but scripts doesn't
seem to run (nor to be run) in frameset section.

(http://prod01site.com would be redirected to
http://myglobalsite.com/index.html?product="prod1.htm", and would load
prod1.htm into "prod" frame).

Is there a way to do this?

You could update the frame's location once the frameset loaded:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>frameset</title>
<script type="text/javascript">
function setProduct() {
var page = self.location.search.match(/[\?&]product=([^&]+)/)[1];
self.frames["prod"].location = page;
}
</script>
</head>
<frameset cols="200,*" onload="setProduct()">
<frame name="contents" frameborder="1" src="menu.htm">
<frame name="prod" frameborder="1" src="about:blank">
</frameset>
</html>

.... but you'd almost always be better off doing this kind of thing on
the server.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top