Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > problem creating a dynamic file/frame pointer in js

Reply
Thread Tools

problem creating a dynamic file/frame pointer in js

 
 
Phil
Guest
Posts: n/a
 
      04-29-2004
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/
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      05-15-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointer to an array vs pointer to pointer subramanian100in@yahoo.com, India C Programming 5 09-23-2011 10:28 AM
Pointer to pointer or reference to pointer A C++ 7 07-05-2011 07:49 PM
Pointer to pointer Vs References to Pointer bansalvikrant@gmail.com C++ 4 07-02-2009 10:20 AM
passing the address of a pointer to a func that doesnt recieve a pointer-to-a-pointer jimjim C Programming 16 03-27-2006 11:03 PM
Pointer-to-pointer-to-pointer question masood.iqbal@lycos.com C Programming 10 02-04-2005 02:57 AM



Advertisments