problem with getElementsByName

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lukaszmn@gmail.com

    problem with getElementsByName

    Hi, I cannot figure out why everything from line "var elem =
    doc.getElements ByName('keyword s')" in x.js is not executed. I want to
    set value of <input name=keywords ...which is in a.html after page
    is loaded.

    ------------------ search.html --------------------

    <html>
    <head>
    <title>Search </title>
    <script src="x.js"/>
    </head>

    <frameset rows="*" onload="load()" >
    <frame src="search-1.html"/>
    </frameset>

    </html>


    ------------------- search-1.html -------------------------

    <html>
    <head>
    <title>Search </title>
    </head>
    <body>

    <iframe src="a.html" height="600" width="600" id="frameSearch ">
    </iframe>


    </body>
    </html>



    ----------------- a.html --------------------------

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>MLdonkey : Web Interface</title>
    </head>
    <body>
    <form action="submit" >
    <input type=text name=keywords size=40 value="">
    </form></html>



    ----------------------------------- x.js
    -------------------------------

    function load() {
    var frame = frames[1].document.getEl ementById('fram eSearch');
    var doc = frame.document;
    var elem = doc.getElements ByName('keyword s');
    alert (elem.length);
    }

  • Tom de Neef

    #2
    Re: problem with getElementsByNa me


    <lukaszmn@gmail .com wrote
    Hi, I cannot figure out why everything from line "var elem =
    doc.getElements ByName('keyword s')" in x.js is not executed. I want to
    set value of <input name=keywords ...which is in a.html after page
    is loaded.
    >
    <snip>
    function load() {
    var frame = frames[1].document.getEl ementById('fram eSearch');
    var doc = frame.document;
    var elem = doc.getElements ByName('keyword s');
    alert (elem.length);
    }
    >
    getElementsByNa me -getElementByNam e
    Tom


    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: problem with getElementsByNa me

      lukaszmn@gmail. com wrote:
      Hi, I cannot figure out why everything from line "var elem =
      doc.getElements ByName('keyword s')" in x.js is not executed.
      I want to [...]
      [Invalid markup]
      ,-<http://jibbering.com/faq/#FAQ4_43>
      | 4.43 How do I get my browser to report javascript errors?

      Is there a point in your posting much the same twice under different authorship?

      ,-<http://jibbering.com/faq/#FAQ2_3>
      | 2.3 What do I have to do before posting to clj?


      PointedEars
      --
      Use any version of Microsoft Frontpage to create your site.
      (This won't prevent people from viewing your source, but no one
      will want to steal it.)
      -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: problem with getElementsByNa me

        Tom de Neef wrote:
        <lukaszmn@gmail .com wrote
        >function load() {
        >var frame = frames[1].document.getEl ementById('fram eSearch');
        >var doc = frame.document;
        >var elem = doc.getElements ByName('keyword s');
        >alert (elem.length);
        >}
        >
        getElementsByNa me -getElementByNam e
        Nonsense.

        <http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259>


        PointedEars
        --
        realism: HTML 4.01 Strict
        evangelism: XHTML 1.0 Strict
        madness: XHTML 1.1 as application/xhtml+xml
        -- Bjoern Hoehrmann

        Comment

        • Janwillem Borleffs

          #5
          Re: problem with getElementsByNa me

          lukaszmn@gmail. com schreef:
          <title>Search </title>
          <script src="x.js"/>
          The script tag MUST be in the form <script ...></script(so, with an
          explicit closing tag)


          JW

          Comment

          • bbla32@op.pl

            #6
            Re: problem with getElementsByNa me

            Thank you all for suggestions. The problem was the IFRAME hadn't been
            loaded before calling the script. I have not found a way to add an
            onload event to the IFRAME, so I decided to use a timeout event.

            Comment

            • webbugtrack@gmail.com

              #7
              Re: problem with getElementsByNa me

              One of 2 possible issues.

              1.) As Janwilliem stated, the script tag must be closed in IE due to
              this bug:
              Issue: #153 Affects: IE5, IE5.5, IE6, IE7 Description: Adding a self closing script tag in IE, causes rendering/execution issues. The scr...


              2.) If you get the script to load, keep in mind there are bugs
              with .getElementByNa me() in IE
              Issue: #411 Affects: IE5, IE5.5, IE6, IE7, IE8 Status: Microsoft has confirmed this will NOT be fixed in IE8 RTM MSIE Feedback ID: 33433...

              and
              Issue: #403 Affects: IE6, IE7 Fixed in: IE8 Beta 2 Related to ( bug 411 ), another bug with getElementsByName( name ); has been noted. If...


              HTH

              Comment

              • Richard Cornford

                #8
                Re: problem with getElementsByNa me

                webbugtrack@gma il.com wrote:
                <snip>
                1.) As Janwilliem stated, the script tag must be closed in IE
                due to this bug:
                <snip>

                It is not a bug for an HTML parser not to be able to cope with a mark-up
                structure that is not allowed in valid HTML.

                Richard.

                Comment

                Working...