Whta's the Story with document.createElement('iframe') in IE?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas 'PointedEars' Lahn

    #16
    Re: Whta's the Story with document.create Element('iframe ') in IE?

    vunet wrote:
    >In IE6 and IE7, if you have to use the name attribute of a dynamic
    >element inserted into the document, you *must* declare the name
    >attribute of the element when calling document.create Element(). After
    >is too late.
    >[...]
    Is this the answer I was looking for?
    You have failed to provide a proper question in the first place!

    This was a lucky guess and does not mean that you did anything OK here.
    Thanks Laurent, I've been through all this dirt from other 'experts' but
    finally got what I need.
    Yeah, so why don't you FOAD now?


    Score adjusted

    PointedEars

    Comment

    • slebetman

      #17
      Re: Whta's the Story with document.create Element('iframe ') in IE?

      On Sep 10, 1:28 am, Henry <rcornf...@rain drop.co.ukwrote :
      (The handling of name attributes is pretty much an irrelevance if you
      never attempt to do anything that relates to them.)
      It is relevant because the code DOES ATTEMPT TO DO SOMETHING WITH THE
      IFRAME NAME. You just failed to read this bit:
      On Sep 9, 6:04 pm, Laurent vilday wrote:
      <a href="http://www.google.fr" target="myIfram e">link</a>
      ^^^^^^^^^^


      Comment

      • The Magpie

        #18
        Re: Whta's the Story with document.create Element('iframe ') in IE?

        vunet wrote:
        >
        With my original question I was hoping to hear what experts think if
        they are familiar with what I am asking.
        >
        Experts are suggesting that using <iframeis basically a bad idea
        unless you have some over-riding reason that you need to use it. In
        virtually all cases, there will be no such reason.

        Comment

        • Henry

          #19
          Re: Whta's the Story with document.create Element('iframe ') in IE?

          Laurent vilday wrote:
          Henry a écrit :
          >On Sep 9, 5:17 pm, vunet wrote:
          ><snip>
          >>With my original question I was hoping to hear what experts
          >>think if they are familiar with what I am asking.
          >>
          >When you get round to asking a question that can be answered
          >you might get an answer.
          >
          Oh come on ! Do you really need to be another PointedEars ?
          You may not appreciate how the discipline of asking a decent question
          promotes both understanding and eliciting worthwhile answers, but it
          looks like you might get a lesson in that today.
          >You mean a form with a TARGET attribute did not (POST) submit
          >in such a way that the response was received as the new
          >contents of an IFRAME with a corresponding NAME attribute?
          >>
          >I POST forms to dynamically created named/IDed IFRAMEs in
          >IE 6+ all the time, so your inability to do so certainly
          >does not indicate that it is impossible.
          >
          LOL, really without any IE6/IE7 hack ?
          That depends on what you consider an IE hack. The code I use works
          fine on a very wide range of browsers including IE 6+ and does not
          branch at all. It does take one action that is necessary to get it
          working properly for IE, but that action is harmless to other
          browsers.
          I doubt it. No, sorry, I have no
          doubt, I *know* by experience it is a lie.
          So you *know* it is a lie? We will see.
          Read *very* carefully this document :
          <http://msdn.microsoft. com/en-us/library/ms536389.aspx>
          <snip>

          Microsoft's browser documentation is notoriously unreliable. And
          they certainly are not (and never have been) a source for
          cross-browser coding advice.
          In IE6 and IE7, if you have to use the name attribute of a
          dynamic element inserted into the document, you *must*
          declare the name attribute of the element when calling
          document.create Element(). After is too late.
          There is no "must" about it.
          in IE6 and IE7 :
          var input = document.create Element('<input name="myInput"> ');
          var iframe = document.create Element('<ifram e name="myIframe" >');
          >
          Anywhere else :
          var input = document.create Element('input' );
          input.name = 'myInput';
          This is successful in IE. The created input element is functional
          and will be successfully submitted as a name/value pair with the
          containing form. Here the issue with name attributes is only that
          form controls created in this way are not then available as
          members of the document, FORM element or its - elements -
          collection using their names, but there are ways around that.
          (The exception being <input type="radio">, which use name
          attributes as part of their mechanism and so are problematic on
          IE).
          var iframe = document.create Element('iframe ');
          iframe.name = 'myIframe';
          >
          Period.
          When properly analysed, to the point of precisely pinning down the
          cause and effect relationship that results in the issue, the
          critical factor is that when an IFRAME element is created on IE
          without a name being provided in the creation process (the call
          to - createElement -) the window object that corresponds with the
          IFRAME is not given a - name - property, and subsequent setting
          of the - name - property of the IFRAME object or its NAME
          attribute (with setAttribute) does not have the side effect of
          setting the - name - attribute of the window object.

          Having pinned that down the solution is simple; it is to directly
          assign to the - name - property of the window object, either just
          before targeting it with links or form submission, or following
          the IFRAMEs insertion into the document. E.G.:-

          <html>
          <head>
          <title></title>
          </head>
          <body>
          <a href="http://www.google.com/"
          target="myIfram e"
          onclick="frames[this.target].name = this.target">li nk</a>
          <script type="text/javascript">
          var iframe = document.create Element('iframe ');
          iframe.id = iframe.name = 'myIframe';
          document.body.a ppendChild(ifra me);
          </script>
          </body>
          </html>

          - and/or:-

          <html>
          <head>
          <title></title>
          </head>
          <body>
          <a href="http://www.google.com/"
          target="myIfram e"
          onclick="frames[this.target].name = this.target">li nk</a>
          <script type="text/javascript">
          var iframe = document.create Element('iframe ');
          iframe.id = iframe.name = 'myIframe';
          document.body.a ppendChild(ifra me);
          frames['myIframe'].name = 'myIframe';
          </script>
          </body>
          </html>

          And those work fine on IE, many other browsers (the scriptable ones
          that support dynamic DOM standard IFRAME creation) and does not
          need to test and branch, while only using the standard call to -
          createElement -. The window - name - setting operations are harmless
          on the browsers that do not need them, and so it is easier/quicker
          to just do it rather than trying to perform some test to see if it
          is necessary, though the test is simple as prior to the assignment
          the IE window object has no name. The same solution applies in
          precisely the same way to form submission.

          But of course your experience tells you that that is all a lie,
          doesn't it? Period.

          Comment

          • Henry

            #20
            Re: Whta's the Story with document.create Element('iframe ') in IE?

            On Sep 9, 10:12 pm, vunet wrote:
            >In IE6 and IE7, if you have to use the name attribute of
            >a dynamic element inserted into the document, you *must*
            >declare the name attribute of the element when calling
            >document.creat eElement(). After is too late.
            >
            >in IE6 and IE7 :
            >var input = document.create Element('<input name="myInput"> ');
            >var iframe = document.create Element('<ifram e name="myIframe" >');
            >
            >Anywhere else :
            >var input = document.create Element('input' );
            >input.name = 'myInput';
            >var iframe = document.create Element('iframe ');
            >iframe.name = 'myIframe';
            >
            Is this the answer I was looking for? Thanks Laurent, I've
            been through all this dirt from other 'experts' but finally
            got what I need.
            If you were only interested in listening to the answer you wanted to
            hear, rather than learning the truth, why did you ask the question in
            the first place? You knew the answer you wanted to hear from the
            outset, so you were just wasting everyone's time asking the question
            in a forum that would rather promote understanding stupid mystical
            incantations.

            Comment

            • Thomas 'PointedEars' Lahn

              #21
              Re: Whta's the Story with document.create Element('iframe ') in IE?

              The Magpie wrote:
              vunet wrote:
              >With my original question I was hoping to hear what experts think if
              >they are familiar with what I am asking.
              >
              Experts are suggesting that using <iframeis basically a bad idea
              unless you have some over-riding reason that you need to use it. In
              virtually all cases, there will be no such reason.
              Hear, hear!


              PointedEars, amused
              --
              Prototype.js was written by people who don't know javascript for people
              who don't know javascript. People who don't know javascript are not
              the best source of advice on designing systems that use javascript.
              -- Richard Cornford, cljs, <f806at$ail$1$8 300dec7@news.de mon.co.uk>

              Comment

              • slebetman

                #22
                Re: Whta's the Story with document.create Element('iframe ') in IE?

                On Sep 10, 6:41 pm, Henry <rcornf...@rain drop.co.ukwrote :
                On Sep 9, 10:12 pm, vunet wrote:
                >
                >
                >
                In IE6 and IE7, if you have to use the name attribute of
                a dynamic element inserted into the document, you *must*
                declare the name attribute of the element when calling
                document.create Element(). After is too late.
                >
                in IE6 and IE7 :
                var input = document.create Element('<input name="myInput"> ');
                var iframe = document.create Element('<ifram e name="myIframe" >');
                >
                Anywhere else :
                var input = document.create Element('input' );
                input.name = 'myInput';
                var iframe = document.create Element('iframe ');
                iframe.name = 'myIframe';
                >
                Is this the answer I was looking for? Thanks Laurent, I've
                been through all this dirt from other 'experts' but finally
                got what I need.
                >
                If you were only interested in listening to the answer you wanted to
                hear, rather than learning the truth, why did you ask the question in
                the first place? You knew the answer you wanted to hear from the
                outset, so you were just wasting everyone's time asking the question
                in a forum that would rather promote understanding stupid mystical
                incantations.
                The answer he was looking for was really the *official* reason why the
                stupid mystical incantation in necessary in the first place which
                Laurent correctly gave:

                In an HTML document, the document.createElement() method creates the HTML element specified by localName, or an HTMLUnknownElement if localName isn't recognized.


                He had to ask in the newsgroup in the first place because he wasn't
                even sure there IS an official reason for it much less where to LOOK
                FOR IT.

                So the question WAS warranted (it's not in the FAQ after all). By the
                way, this so called stupid mystical incantation is necessary in IE for
                other things besides iframes. It's necessary for selects, inputs and
                textareas. It may be necessary for other tags as well but I've mostly
                found problems with form elements. Basically, document.create Element
                is b0rk in IE.

                Comment

                • Thomas 'PointedEars' Lahn

                  #23
                  Re: Whta's the Story with document.create Element('iframe ') in IE?

                  slebetman wrote:
                  On Sep 10, 6:41 pm, Henry <rcornf...@rain drop.co.ukwrote :
                  >On Sep 9, 10:12 pm, vunet wrote:
                  >>>In IE6 and IE7, if you have to use the name attribute of
                  >>>a dynamic element inserted into the document, you *must*
                  >>>declare the name attribute of the element when calling
                  >>>document.cre ateElement(). After is too late.
                  >>>in IE6 and IE7 :
                  >>>var input = document.create Element('<input name="myInput"> ');
                  >>>var iframe = document.create Element('<ifram e name="myIframe" >');
                  >>>Anywhere else :
                  >>>var input = document.create Element('input' );
                  >>>input.name = 'myInput';
                  >>>var iframe = document.create Element('iframe ');
                  >>>iframe.nam e = 'myIframe';
                  >>Is this the answer I was looking for? Thanks Laurent, I've
                  >>been through all this dirt from other 'experts' but finally
                  >>got what I need.
                  >If you were only interested in listening to the answer you wanted to
                  >hear, rather than learning the truth, why did you ask the question in
                  >the first place? You knew the answer you wanted to hear from the
                  >outset, so you were just wasting everyone's time asking the question
                  >in a forum that would rather promote understanding stupid mystical
                  >incantations .
                  >
                  The answer he was looking for was really the *official* reason why the
                  stupid mystical incantation in necessary in the first place
                  Nonsense. Read the OP again.
                  That may be what you consider official, but it is nonsense nonetheless.
                  Turns out the vendor does not even know its own product or is incapable
                  of expressing its flaws properly in the documentation.
                  He had to ask in the newsgroup in the first place because he wasn't
                  even sure there IS an official reason for it much less where to LOOK
                  FOR IT.
                  This "official reason" excuse is a byproduct of your vivid imagination. The
                  OP asked why it was done this way, and the correct answer is that the author
                  of the code had no clue what they were doing. Because a reasonable
                  developer double-checks everything that he reads.
                  So the question WAS warranted (it's not in the FAQ after all).
                  There is no doubt about that. However, that the OP assumed that what he
                  read was the only correct way because a million flies already said so, was
                  presumptuous and turned out to be wrong.
                  By the way, this so called stupid mystical incantation is necessary in IE for
                  other things besides iframes. It's necessary for selects, inputs and
                  textareas. It may be necessary for other tags as well but I've mostly
                  found problems with form elements. Basically, document.create Element
                  is b0rk in IE.
                  You have not read or tested "Henry"'s code, have you?


                  PointedEars
                  --
                  var bugRiddenCrashP ronePieceOfJunk = (
                  navigator.userA gent.indexOf('M SIE 5') != -1
                  && navigator.userA gent.indexOf('M ac') != -1
                  ) // Plone, register_functi on.js:16

                  Comment

                  • Henry

                    #24
                    Re: Whta's the Story with document.create Element('iframe ') in IE?

                    On Sep 10, 11:36 pm, slebetman wrote:
                    On Sep 10, 6:41 pm, Henry wrote:
                    >On Sep 9, 10:12 pm, vunet wrote:
                    >
                    >>>In IE6 and IE7, if you have to use the name attribute of
                    >>>a dynamic element inserted into the document, you *must*
                    >>>declare the name attribute of the element when calling
                    >>>document.cre ateElement(). After is too late.
                    >
                    >>>in IE6 and IE7 :
                    >>>var input = document.create Element('<input name="myInput"> ');
                    >>>var iframe = document.create Element('<ifram e name="myIframe" >');
                    >
                    >>>Anywhere else :
                    >>>var input = document.create Element('input' );
                    >>>input.name = 'myInput';
                    >>>var iframe = document.create Element('iframe ');
                    >>>iframe.nam e = 'myIframe';
                    >
                    >>Is this the answer I was looking for? Thanks Laurent, I've
                    >>been through all this dirt from other 'experts' but finally
                    >>got what I need.
                    >
                    >If you were only interested in listening to the answer you
                    >wanted to hear, rather than learning the truth, why did you
                    >ask the question in the first place? You knew the answer you
                    >wanted to hear from the outset, so you were just wasting
                    >everyone's time asking the question in a forum that would
                    >rather promote understanding stupid mystical incantations.
                    >
                    The answer he was looking for was really the *official* reason
                    why the stupid mystical incantation in necessary in the first
                    place
                    The answer to that is that it is *not* necessarily. And that answer
                    was given, but apparently that answer, no matter its demonstrable
                    truth, was not the answer he was looking for.
                    which Laurent correctly gave:
                    <snip>

                    You cannot "correctly" give a reason for the necessity of something
                    that is not necessary.
                    He had to ask in the newsgroup in the first place because
                    he wasn't even sure there IS an official reason for it
                    But he was not interested in listening when he was told that there was
                    not.
                    much less where to LOOK FOR IT.
                    There can be no "where to look" for the reason for the necessity of
                    something that is not necessary.
                    So the question WAS warranted
                    Not if the answer was pre-determined by ill-conceived preconceptions.
                    (it's not in the FAQ after all).
                    Difficult to pot the absence of a reason for the necessity of
                    something into any document. But it any event it is a long way from
                    being a frequently asked question.
                    By the way, this so called stupid mystical incantation is
                    necessary in IE for other things besides iframes.
                    It is not necessary for IFRAMEs, and (unsurprisingly ) also unnecessary
                    for anything else.
                    It's necessary for selects, inputs and
                    textareas.
                    In what way? IE happily creates input, select and textarea elements
                    for me using DOM standard element creation code. (<input type="radio">
                    are the only elements that need special handling as a result of IE's
                    characteristics , and I still use non-branching code for those).
                    It may be necessary for other tags as well but I've mostly
                    found problems with form elements.
                    Your finding problems with the code you write is not, in itself, a
                    reason to be attributing issues to the wider world.
                    Basically, document.create Element
                    is b0rk in IE.
                    Based on what evidence? The case of targeting links and form
                    submission not being as simple as it could be has nothing to do with
                    the - createElement -, but rather is a consequence of employing -
                    setAttribute - and/or assigning to the element's - name - property not
                    having the side effect of associating a name with the corresponding
                    window object in IE. Thus if anything is broken it is the assignment
                    to the element's - name - property and/or - setAttribute -. And here
                    is a reflection of my point about the quality of analysis being so
                    poor that people fixate on mystical inactions that never do much more
                    that solve issues by coincidence; you are blaming the - createElement
                    - method, when with the argument "IFRAME" IE's - createElement -
                    method does no more and no less than any other - createElement -
                    method (creates a IFRAME element that is not attached to a document
                    and has no more than default/implied properties/attributes, and
                    certainly no name or id).

                    Comment

                    Working...