Variable lost with each function call - WHY?

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

    #1

    Variable lost with each function call - WHY?

    This is my code:

    <script language="JavaS cript" type="text/javascript">
    <!--
    desc_switch = 0;
    function description (desc,type) {
    // onBlur
    alert(desc_swit ch)
    if (type == 3) {
    desc_switch = 0;
    description_are a.innerHTML = desc;
    }
    // onFocus
    else if (type == 2) {
    desc_switch = 1;
    description_are a.innerHTML = desc;
    }
    // onMouseOut
    else if ((type == 1) && (desc_switch == 0)) {
    description_are a.innerHTML = desc;
    }
    // onMouseOver
    else {
    description_are a.innerHTML = desc;
    desc_switch = 0;
    }
    }
    // -->
    </script>

    <input type="text" name="name" maxlength="50" value="http://"
    onMouseOver="de scription('Your ',0);" onMouseOut="des cription('',1); "
    onFocus="descri ption('Your',2) ;" onBlur="descrip tion('',3);">

    I would _really_ appreciate any help on this issue.

    Keiron


  • DJ WIce

    #2
    Re: Variable lost with each function call - WHY?

    : This is my code:
    <snip> </snip>
    : <input type="text" name="name" maxlength="50" value="http://"
    : onMouseOver="de scription('Your ',0);" onMouseOut="des cription('',1); "
    : onFocus="descri ption('Your',2) ;" onBlur="descrip tion('',3);">

    onFocus and onMouseOver are happening at the same time.
    onBlur and onMouseOut are happening at the same time.

    (in MSIE, test it in NN and you might get an other result).
    Wouter





    Comment

    • Keiron Waites

      #3
      Re: Variable lost with each function call - WHY?


      "DJ WIce" <contextmenu @ djwice.com> wrote in message
      news:bv6rsc$l4a $1@news.tudelft .nl...[color=blue]
      > : This is my code:
      > <snip> </snip>
      > : <input type="text" name="name" maxlength="50" value="http://"
      > : onMouseOver="de scription('Your ',0);" onMouseOut="des cription('',1); "
      > : onFocus="descri ption('Your',2) ;" onBlur="descrip tion('',3);">
      >
      > onFocus and onMouseOver are happening at the same time.
      > onBlur and onMouseOut are happening at the same time.
      >
      > (in MSIE, test it in NN and you might get an other result).
      > Wouter[/color]

      So it is possible for a function to be called at exactly the same time? It's
      not necessary for all function calls to go 1 by 1?

      Thanks


      Comment

      • DJ WIce

        #4
        Re: Variable lost with each function call - WHY?

        : > onFocus and onMouseOver are happening at the same time.
        : > onBlur and onMouseOut are happening at the same time.
        : >
        : > (in MSIE, test it in NN and you might get an other result).
        : > Wouter
        :
        : So it is possible for a function to be called at exactly the same time?
        It's
        : not necessary for all function calls to go 1 by 1?

        I don't know. I'm sure that 'exactly' it shall not be.
        I noticed that MSIE might 'forget' to handle the second event if it handled
        the first one.
        (else onmousedown and oncontextmenu would both be triggered on a right
        click, that only happens in NN not in MSIE).

        But why or how, I don't know. And maybe I'm just wrong.

        Wouter


        Comment

        • Richard Cornford

          #5
          Re: Variable lost with each function call - WHY?

          "Keiron Waites" <no@thanks.co m> wrote in message
          news:bv6sfr$8ck $1@sparta.btint ernet.com...
          <snip>[color=blue][color=green]
          >>onFocus and onMouseOver are happening at the same time.
          >>onBlur and onMouseOut are happening at the same time.
          >>
          >>(in MSIE, test it in NN and you might get an other result).
          >>Wouter[/color]
          >
          >So it is possible for a function to be called at exactly the
          >same time? It's not necessary for all function calls to go 1
          >by 1?[/color]

          It is not possible for events of different types to occur simultaneously
          on IE browsers because they use a single global - event - property to
          hold the references to the event objects. Each single event must be
          fully processed (end of bubbling) before processing of the next event
          can begin. Else the browser would have to put a great deal of effort
          into keeping track of which event handlers were active and continually
          swap the global event reference, and even then no two different event
          objects could be referenced via the one global - event - property at the
          same time.

          Richard.


          Comment

          • Brian Genisio

            #6
            Re: Variable lost with each function call - WHY?

            Keiron Waites wrote:
            [color=blue]
            > This is my code:
            >
            > <script language="JavaS cript" type="text/javascript">
            > <!--
            > desc_switch = 0;
            > function description (desc,type) {
            > // onBlur
            > alert(desc_swit ch)
            > if (type == 3) {
            > desc_switch = 0;
            > description_are a.innerHTML = desc;
            > }
            > // onFocus
            > else if (type == 2) {
            > desc_switch = 1;
            > description_are a.innerHTML = desc;
            > }
            > // onMouseOut
            > else if ((type == 1) && (desc_switch == 0)) {
            > description_are a.innerHTML = desc;
            > }
            > // onMouseOver
            > else {
            > description_are a.innerHTML = desc;
            > desc_switch = 0;
            > }
            > }
            > // -->
            > </script>
            >
            > <input type="text" name="name" maxlength="50" value="http://"
            > onMouseOver="de scription('Your ',0);" onMouseOut="des cription('',1); "
            > onFocus="descri ption('Your',2) ;" onBlur="descrip tion('',3);">
            >
            > I would _really_ appreciate any help on this issue.
            >
            > Keiron
            >
            >[/color]

            What does description_are a do? I see no reference to it. If I take the
            description_are a lines (which my browser fails on) out, the desc_switch
            does not loose it's value.

            Brian

            Comment

            Working...