469,645 Members | 1,181 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

JS code inside frameset..


can u put JS code inside a frameset? I have this, and it's not working,
even test alerts are ignored, in both browsers.. thank you..
Frances Del Rio
<frameset rows="90,*" border=0 frameborder="0" framespacing="0">
<frame name="header" src="header.html" scrolling="no" frameborder="0">
<script language="Javascript">
if(navigator.appName == "Netscape"){
alert('ha')
document.write("<frameset cols='120,*' frameborder='0' framespacing='0'>")
}
else {
alert('ha')
document.write("<frameset cols='112,*' frameborder='0' framespacing='0'>")
}
</script>

<frame name="nav" src="menu.html" scrolling="no" frameborder="0">
<frame name="main" src="check_puid.jsp" scrolling="auto" frameborder="0">
</frameset>

Jul 23 '05 #1
8 2604
Ron
Frances Del Rio wrote:

can u put JS code inside a frameset? I have this, and it's not
working, even test alerts are ignored, in both browsers.. thank you..
Frances Del Rio
<frameset rows="90,*" border=0 frameborder="0" framespacing="0">
<frame name="header" src="header.html" scrolling="no" frameborder="0">
<script language="Javascript">
if(navigator.appName == "Netscape"){
alert('ha')
document.write("<frameset cols='120,*' frameborder='0'
framespacing='0'>")
}
else {
alert('ha')
document.write("<frameset cols='112,*' frameborder='0'
framespacing='0'>")
}
</script>

<frame name="nav" src="menu.html" scrolling="no" frameborder="0">
<frame name="main" src="check_puid.jsp" scrolling="auto" frameborder="0">
</frameset>

script elements are not allowed in frameset elements ->
http://www.w3.org/TR/html401/present....html#h-16.2.1 . Put your
script in the head element instead.
Jul 23 '05 #2
bummer........
script elements are not allowed in frameset elements ->
http://www.w3.org/TR/html401/present....html#h-16.2.1 . Put your
script in the head element instead.
well, that's not of much use to me.. I need one frame with for Netscape
(N 4.7, I'm talking, hence the problem..) and another width for same
frame in IE.. thank you yr response.. Frances

Frances Del Rio wrote:

can u put JS code inside a frameset? I have this, and it's not
working, even test alerts are ignored, in both browsers.. thank you..
Frances Del Rio
<frameset rows="90,*" border=0 frameborder="0" framespacing="0">
<frame name="header" src="header.html" scrolling="no" frameborder="0">
<script language="Javascript">
if(navigator.appName == "Netscape"){
alert('ha')
document.write("<frameset cols='120,*' frameborder='0'
framespacing='0'>")
}
else {
alert('ha')
document.write("<frameset cols='112,*' frameborder='0'
framespacing='0'>")
}
</script>
<frame name="nav" src="menu.html" scrolling="no" frameborder="0">
<frame name="main" src="check_puid.jsp" scrolling="auto" frameborder="0">
</frameset>


Jul 23 '05 #3
Frances Del Rio wrote:
bummer........
?
> script elements are not allowed in frameset elements ->
> http://www.w3.org/TR/html401/present....html#h-16.2.1 . Put your
> script in the head element instead.


well, that's not of much use to me..


It is. Since you cannot use the "script" element within the "frameset"
element, but you *can* use it within the "head" element, you should do so.
See <40**************@PointedEars.de>.
[Top post]


Please take heed of <http://jibbering.com/faq/#FAQ2_3>.
PointedEars
Jul 23 '05 #4
Lee
Frances Del Rio said:

bummer........
script elements are not allowed in frameset elements ->
http://www.w3.org/TR/html401/present....html#h-16.2.1 . Put your
script in the head element instead.


well, that's not of much use to me.. I need one frame with for Netscape
(N 4.7, I'm talking, hence the problem..) and another width for same
frame in IE.. thank you yr response.. Frances


Tested in Netscape 7 and IE6:

<html>
<head>
<script type="text/javascript">
var cols=(navigator.appName == "Netscape")?120:112;
var html=[
'<frameset rows="90,*" border=0 frameborder="0" framespacing="0">',
'<frame name="header" src="header.html" scrolling="no" frameborder="0">',
"<frameset cols='"+cols+",*' frameborder='0' framespacing='0'>",
'<frame name="nav" src="menu.html" scrolling="no" frameborder="0">',
'<frame name="main" src="check_puid.jsp" scrolling="auto" frameborder="0">',
'</frameset></frameset>'
];
document.write(html.join(""));
</script>
</head>
</html>

Jul 23 '05 #5
Lee wrote:
var cols=(navigator.appName == "Netscape")?120:112;
var html=[
'<frameset rows="90,*" border=0 frameborder="0" framespacing="0">',
'<frame name="header" src="header.html" scrolling="no" frameborder="0">',
"<frameset cols='"+cols+",*' frameborder='0' framespacing='0'>",
'<frame name="nav" src="menu.html" scrolling="no" frameborder="0">',
'<frame name="main" src="check_puid.jsp" scrolling="auto" frameborder="0">',
'</frameset></frameset>'
];
document.write(html.join(""));


Nice one. But as for legibility of the resulting code, one should rather use

document.write(html.join("\n"));

And note that Array object initializers are not supported by all script
engines, so you may want to use

var html = new Array(
...
);

as well. However, browser sniffing does not work:

<http://pointedears.de/scripts/test/whatami>
PointedEars
Jul 23 '05 #6
On Fri, 28 May 2004 23:31:21 +0200, Thomas 'PointedEars' Lahn
<Po*********@nurfuerspam.de> wrote:
Nice one. But as for legibility of the resulting code, one should rather use

document.write(html.join("\n"));


I'd recommend "" - the fewer redundant nodes you have in the DOM the
better - why would you be reading generated code anyway?

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 23 '05 #7
Lee
Thomas 'PointedEars' Lahn said:

Lee wrote:
var cols=(navigator.appName == "Netscape")?120:112;
var html=[
'<frameset rows="90,*" border=0 frameborder="0" framespacing="0">',
'<frame name="header" src="header.html" scrolling="no" frameborder="0">',
"<frameset cols='"+cols+",*' frameborder='0' framespacing='0'>",
'<frame name="nav" src="menu.html" scrolling="no" frameborder="0">',
'<frame name="main" src="check_puid.jsp" scrolling="auto" frameborder="0">',
'</frameset></frameset>'
];
document.write(html.join(""));


Nice one. But as for legibility of the resulting code, one should rather use

document.write(html.join("\n"));

And note that Array object initializers are not supported by all script
engines, so you may want to use

var html = new Array(
...
);

as well. However, browser sniffing does not work:

1. During testing, I did join a newline, and alerted the result.
I changed it to "" and deleted the alert for release.

2. This is probably the first time I've used browser sniffing,
and did so only because the OP's requirement was to have a
different frame size in Netscape, specifically. Personally,
I would try to avoid such a requirement.

Jul 23 '05 #8
Jim Ley wrote:
[...] Thomas 'PointedEars' Lahn [...] wrote:
Nice one. But as for legibility of the resulting code, one should
rather use

document.write(html.join("\n"));
I'd recommend "" - the fewer redundant nodes you have in the DOM the
better -


Generally, agreed. But it is unlikely that someone
will access the top frameset element with the DOM.
why would you be reading generated code anyway?


To see that it worked.
PointedEars
Jul 23 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Hans | last post: by
1 post views Thread by Mark Kuiphuis | last post: by
13 posts views Thread by Andrew C. | last post: by
2 posts views Thread by Pat Sheen | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.