problem creating a dynamic file/frame pointer in js

P

Phil

Supposedly, the code below should assign the correct value to the
'url' variable.
But all I get is a blank 'main' Frame with apparently nowhere to go
when I
click
on the link in the 'menu' Frame..
Worst(yesyes!!)
1 - Explorer 6 : clicking a link in the 'menu' frame simple reopens an
instance of the FRAMESET, syntax error msg.
2 - Netscape 7.1 : clicking a link in the 'menu' frame simple reopens
an instance of the FRAMESET, but does not report ANY errors in the
Java console.
3 - Mozilla 5.0: same as Netscape.
Opera 7.23 however WILL (after a little) opens as expected, but
right-clicking a link(open in a new window) does not retrieve the page
name of the clicked link, instead it re-opens the menu page alone in a
new window.

What a headache. Can someone help me please?TIA

<HTML>
<SCRIPT type="text/javascript">
var theData;
var begin;
var url;
begin = top.location.href.indexOf("?");
if (begin > 0 ) {
theData = top.location.href.substring(begin+1,location.href.length);
theData = unescape(theData);
url = "<FRAME name=main src='files/" + theData; + "'>";
} else {
url = "<FRAME name=main src='files/Help.htm'>";
}
</script>
<FRAMESET cols="20%,*" FRAMEBORDER="1" BORDER="1" scrolling="auto">
<noframes>
</noframes>
<FRAME name=menu src='files/menu.html' marginwidth='0'
marginheight='0' target='main'>
<script type="text/javascript">
document.write(url);
<script>
</FRAMESET>
</HTML>
BTW, the code I use at the moment is very inelegant, you can view it
there:
http://philippeoget.50megs.com/
 
T

Thomas 'PointedEars' Lahn

Phil said:
Supposedly, the code below should assign the correct value to the
'url' variable.
But all I get is a blank 'main' Frame with apparently nowhere to go
when I click on the link in the 'menu' Frame..
Worst(yesyes!!)
[problems with common browsers]
What a headache. Can someone help me please?TIA

[source code]
BTW, the code I use at the moment is very inelegant, [...]

and invalid which is the reason of the errors you noticed.
You might want to consider this:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Static frameset (use a better title here)</title>
<script type="text/javascript">
if (typeof document != "undefined"
&& typeof document.open != "undefined"
&& typeof document.write != "undefined"
&& typeof document.close != "undefined")
{
var mainSrc = "Help.htm";
var s = "";
if (typeof top != "undefined"
&& typeof top.location != "undefined"
&& typeof top.location.search != "undefined"
&& typeof top.location.search.replace != "undefined"
&& (s = top.location.search.replace(/^\?/, ""))
{
mainSrc = typeof unescape != "undefined" ? unescape(s) : s;
}

document.open("text/html");
document.write(
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"'
+ ' "http://www.w3.org/TR/html4/frameset.dtd">'
+ '<html>'
+ '<head>'
+ '<title>Frameset generated by client-side script'
+ ' (use a better title here, maybe dynamic)<\/title>'
+ '<\/head>'
+ '<frameset cols="20%,*">'
+ '<frame name="menu" src="files/menu.html" marginwidth="0"'
+ ' marginheight="0">'
+ '<frame name="main" src="files/' + mainSrc + '">'
+ '<noframes>'
+ '<body>'
+ 'useful alternative content'
+ '<\/body>'
+ '<\/noframes>'
+ '<\/frameset>'
+ '<\/html>');
document.close();
}
</script>
</head>

<frameset cols="20%,*">
<frame name="menu" src="files/menu.html" marginwidth="0"
marginheight="0">
<frame name="main" src="files/Help.htm">

<noframes>
<body>
useful alternative content
</body>
</noframes>
</frameset>
</html>

This will at least be valid and will not exclude users without
client-side script support. However, a server-side solution
will be much less error-prone and much more performant.


PointedEars
 

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,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top