469,281 Members | 2,484 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

problem creating a dynamic file/frame pointer in js

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/
Jul 23 '05 #1
1 1467
Phil wrote:
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
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by David | last post: by
reply views Thread by RJS | last post: by
3 posts views Thread by Tony Johansson | last post: by
reply views Thread by mharris | last post: by
2 posts views Thread by ajikoe | last post: by
13 posts views Thread by xian_hong2046 | last post: by
11 posts views Thread by toton | last post: by
reply views Thread by ishakteyran | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.