IE and window.name

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

    #1

    IE and window.name

    Hi,

    excuse me in advance for my poor english...

    Do you know how solve my problem ?

    I have "Page1.htm" :

    <HTML><BODY>
    <A href="Page2.htm " target=TOTO>win dow TOTO</A>
    </BODY></HTML>

    and I have "Page2.htm" :

    <HTML><HEAD>
    <SCRIPT>
    function affName(i) { alert( i +" - "+ window.name ); }

    affName(1);
    window.name = "TITI";
    affName(2);

    </SCRIPT>
    </HEAD><BODY onload="affName (3);">
    <A href="javascrip t:affName(4)">w indow.name ?</A>
    </BODY></HTML>

    When I click on "fenetre TOTO" link of "Page1", a window is opened (OK)
    and we have alerts :

    1 - TOTO
    2 - TITI
    3 - TITI

    All is right : "window.nam e" is changed from TOTO to TITI.

    My problem is when I click on the "window.nam e ?" link of "Page2".

    With NS 7, NS4+, we have :
    4 - TITI ==> OK
    With IE, we have :
    4 - TOTO ==> Why ?

    Any help would be highly appreciated.
    Thank you very much in advance.

    --
    Yours sincerely, Thierry
  • Richard Cornford

    #2
    Re: IE and window.name

    Cenekemoi wrote:
    <snip>[color=blue]
    > <A href="javascrip t:affName(4)">w indow.name ?</A>[/color]
    <snip>[color=blue]
    > With NS 7, NS4+, we have :
    > 4 - TITI ==> OK
    > With IE, we have :
    > 4 - TOTO ==> Why ?[/color]
    <snip>

    The use of a javascript pseudo-protocol HREF. The general rule is; if
    you use a javascript pseudo-protocol HREF (other than as a source of
    content replacing HTML source code in the form of a javascript string)
    all bets are off as to what will happen/function afterwards. They should
    not ever be used in cross-browser scripting to execute side-effect
    functions, or as null/void hrefs.

    Change the line to:-

    <A href="#" onclick="affNam e(4);return false;">window. name ?</A>

    - and the window name reported is as expected.
    [color=blue]
    >Yours sincerely, Thierry[/color]

    In English 'Yours sincerely' is used when you know (and have stated) the
    name of the recipient of the communication, which cannot be true in this
    case. 'Yours faithfully' is formally correct in this context (if maybe a
    bit too formal).

    Richard.


    Comment

    • Cenekemoi

      #3
      Re: IE and window.name

      Bonjour à Richard Cornford qui nous a écrit :[color=blue]
      > Change the line to:-
      >
      > <A href="#" onclick="affNam e(4);return false;">window. name ?</A>
      >
      > - and the window name reported is as expected.[/color]

      I'm sorry, but the result is exactly le same that with
      "javascript:aff Name(4)". Even if you are right, it is not the solution
      for my problem. Had you tried yourself ?
      [color=blue][color=green]
      >> Yours sincerely, Thierry[/color]
      >
      > In English 'Yours sincerely' is used when you know (and have stated)
      > the name of the recipient of the communication, which cannot be true
      > in this case. 'Yours faithfully' is formally correct in this context
      > (if maybe a bit too formal).
      >
      > Richard.[/color]

      Thank you for your comment...

      --
      Cordialement, Thierry ;-)

      Comment

      • Richard Cornford

        #4
        Re: IE and window.name

        Cenekemoi wrote:[color=blue]
        > Richard Cornford wrote:[color=green]
        >> Change the line to:-
        >><A href="#" onclick="affNam e(4);return false;">window. name ?</A>
        >>
        >> - and the window name reported is as expected.[/color]
        >
        > I'm sorry, but the result is exactly le same that with
        > "javascript:aff Name(4)". Even if you are right, it is not
        > the solution for my problem. Had you tried yourself ?[/color]
        <snip>

        Of course I tried it. I had to verify that the code you posted exhibited
        the symptoms described. As it did, and the javascript pseudo-protocol is
        a notorious troublemaker, I experimented with moving the code to an
        onclick handler, and the symptoms went away in IE 6.

        Richard.


        Comment

        • RobG

          #5
          Re: IE and window.name

          Cenekemoi wrote:
          [color=blue]
          > Bonjour à Richard Cornford qui nous a écrit :[/color]
          [color=blue]
          > I'm sorry, but the result is exactly le same that with
          > "javascript:aff Name(4)". Even if you are right, it is not the solution
          > for my problem.[/color]


          Cenekemoi,

          the window.name attribute is DOM level 0, which means (I think) it is a legacy supported feature that existed prior to the formalisation of the DOM, hence support is problematic.

          If you add a button to Page2.htm and check window.name *before* clicking your href link, you will see that "window.nam e" when the window is loaded is indeed set to TITI by the script in the header. When your link is clicked, "window.nam e" reverts to TOTO - clicking on the button after clicking on your link gives "TOTO" too.

          All I can suggest is that you call window.name directly, do you need the affName function?


          New Page2.htm

          <html><head>
          <script type="text/javascript">
          function affName(i) {
          alert( i +" - "+ window.name );
          }
          affName(1);
          window.name = "TITI";
          affName(2);
          </script>
          </head><body onload="affName (3);">
          <form>
          <input type="button" value="click"
          onclick="alert( window.name);">
          </form>
          <br>
          <a href="javascrip t:affName(4)">w indow.name ?</a>
          </body></html>


          Regards, Rob.

          Comment

          Working...