problem with insertAdjacentHTML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil

    problem with insertAdjacentHTML

    Hi all,

    I am trying to use the code below so as to create a frame source string
    dynamically. The idea is to verify if this index page is the parent or if it
    called by an orphan page, in which case the orphan page passes its own name
    as an argument to the index page.
    Unfortunately, the code below returns an unspecified error.
    This code is what is intended to create the index.htm page as it opens.

    <HTML><TITLE>.. ..</TITLE>

    <SCRIPT type="text/javascript">
    function window.onload()
    {
    checklocation() ;
    }
    function writetop()
    {
    document.body.i nsertAdjacentHT ML('beforeEnd', '<FRAMESET cols=20%,*
    FRAMEBORDER="1" BORDER="1" scrolling=auto> ')
    document.body.i nsertAdjacentHT ML('beforeEnd', '<noframes>')
    document.body.i nsertAdjacentHT ML('beforeEnd', '</noframes>')
    }
    function writebottom()
    {
    document.body.i nsertAdjacentHT ML('beforeEnd', '</FRAMESET>')
    document.body.i nsertAdjacentHT ML('beforeEnd', '</HTML>')
    }
    function checklocation()
    {
    //alert(top.locat ion.href.length );
    var theData;
    var begin;
    begin = top.location.hr ef.indexOf("?") ;
    if (begin > 0 )
    {
    theData = top.location.hr ef.substring(be gin+1,location. href.length);
    theData = unescape(theDat a);
    writetop();
    document.body.i nsertAdjacentHT ML('beforeEnd', '<FRAME name=main
    src="files/ + theData + ">')
    }
    else{
    writetop();
    document.body.i nsertAdjacentHT ML('beforeEnd', '<FRAME name=main
    src="files/Help.htm">')
    }
    writebottom();
    }
    </script>
    <body>

    </body>
    </html>
    TIA
    Phil

  • Mike

    #2
    Re: problem with insertAdjacentH TML

    Here is perhaps a simplier way to accomplish your goals:

    <HTML><TITLE>.. ..</TITLE>

    <SCRIPT type="text/javascript">
    //alert(top.locat ion.href.length );
    var theData;
    var begin;
    var url = "files/Help.htm";
    begin = top.location.hr ef.indexOf("?") ;
    if (begin > 0 )
    {
    theData = top.location.hr ef.substring(be gin+1,location. href.length);
    theData = unescape(theDat a);
    url = "files/ + theData;
    }
    </script>
    <FRAMESET cols="20%,*" FRAMEBORDER="1" BORDER="1" scrolling="auto ">
    <script type="text/javascript">
    document.write( "<FRAME name=main src='"+ url+"'>";
    </script>
    </FRAMESET>
    </html>


    One thing to notice is that you are missing a FRAME definition. I don't know
    if that is intentional or not but perhaps that is the reason for your error
    because you specify 2 frames in your frameset (cols="20%,*) but then only
    define one.




    Comment

    • Philippe Oget

      #3
      Re: problem with insertAdjacentH TML


      The missing frame reference was unintentional but is present in the
      'real' frameset.
      In regard to your code: simple and graceful are 2 words that come to
      mind.

      Many thanks

      Philippe



      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Mick White

        #4
        Re: problem with insertAdjacentH TML

        Mike wrote:
        [color=blue]
        > Here is perhaps a simplier way to accomplish your goals:
        >
        > <HTML><TITLE>.. ..</TITLE>
        >
        > <SCRIPT type="text/javascript">
        > //alert(top.locat ion.href.length );
        > var theData;
        > var begin;
        > var url = "files/Help.htm";
        > begin = top.location.hr ef.indexOf("?") ;
        > if (begin > 0 )
        > {
        > theData = top.location.hr ef.substring(be gin+1,location. href.length);
        > theData = unescape(theDat a);
        > url = "files/ + theData;
        > }
        > </script>
        >[/color]

        You are missing quotes after "files/
        Even simpler below?
        <SCRIPT type="text/javascript">
        var url = "files/Help.htm";
        if (top.location.s earch ){
        url = "files/" + unescape(top.lo cation.search.s ubstring(1))
        }
        </script>

        Mick

        Comment

        Working...