problem creating a dynamic file/frame pointer in js

Discussion in 'Javascript' started by Phil, Apr 29, 2004.

  1. Phil

    Phil Guest

    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/
    Phil, Apr 29, 2004
    #1
    1. Advertising

  2. 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
    Thomas 'PointedEars' Lahn, May 15, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. anonymous
    Replies:
    3
    Views:
    386
    S.Tobias
    Jan 13, 2005
  2. anonymous
    Replies:
    4
    Views:
    735
    S.Tobias
    Jan 28, 2005
  3. Replies:
    10
    Views:
    673
    Chris Torek
    Feb 4, 2005
  4. jimjim
    Replies:
    16
    Views:
    824
    Jordan Abel
    Mar 28, 2006
  5. code break

    stack pointer and frame pointer

    code break, Oct 18, 2006, in forum: C Programming
    Replies:
    4
    Views:
    556
    Walter Roberson
    Oct 18, 2006
Loading...

Share This Page