Sylvan012
06-07-2006, 08:37 AM
I have a question about how IE renders JavaScipt, compared to Firefox.
It would appear that when you put a javascript:function(); in an <a href=""> that also has an "onClick='someOtherFunction();'" command associated with it, IE will execute the <a href="javascript:function();"> first and, then, move on to whatever the onClick wants it to do. Firefox, it would appear, stores all click activities in a buffer associated with that link, somewhere, -in order- and then executes the JavaScript commands.
The reason I think this is that I was working on a Shopping Cart's "RemoveQty" function, this morning, adding a nag pop-up window that would spell out the "virtues" of placing the item just removed, back in the cart. I put a "removeQty" function call in the onClick section and the "openNewPopupWindow" in the <a href="javascript:"> section.
The result of this was that IE was changing the amount in the cart to "0" (but not actually removing the selected product from the cart) while opening the new popup window. Since "RemoveQty()" submits the Shopping Cart form to the server, it was as if the browser was stopping execution before it could finish: it would decriment the product's Quantity to 0, allright, but not actually send that change to the server.
Firefox removed the item, refreshed the screen, and opened the popup window.
I am guessing that this is because IE moved the focus away from the main Shopping Cart page to the new popup window and -somehow- stopped execution of the full "removeQty" script. In order to get it working equally on both browsers, all I had to do was swap the order of the javascript executions, putting the RemoveQty() in the <a href="javascript:"> and adding the openNewPopupWindow to the "onClick=" section.
Has anyone run into this before and can anyone confirm that my guess as to why it functioned this way is correct?
Yours with curiosity,
Sylvan
It would appear that when you put a javascript:function(); in an <a href=""> that also has an "onClick='someOtherFunction();'" command associated with it, IE will execute the <a href="javascript:function();"> first and, then, move on to whatever the onClick wants it to do. Firefox, it would appear, stores all click activities in a buffer associated with that link, somewhere, -in order- and then executes the JavaScript commands.
The reason I think this is that I was working on a Shopping Cart's "RemoveQty" function, this morning, adding a nag pop-up window that would spell out the "virtues" of placing the item just removed, back in the cart. I put a "removeQty" function call in the onClick section and the "openNewPopupWindow" in the <a href="javascript:"> section.
The result of this was that IE was changing the amount in the cart to "0" (but not actually removing the selected product from the cart) while opening the new popup window. Since "RemoveQty()" submits the Shopping Cart form to the server, it was as if the browser was stopping execution before it could finish: it would decriment the product's Quantity to 0, allright, but not actually send that change to the server.
Firefox removed the item, refreshed the screen, and opened the popup window.
I am guessing that this is because IE moved the focus away from the main Shopping Cart page to the new popup window and -somehow- stopped execution of the full "removeQty" script. In order to get it working equally on both browsers, all I had to do was swap the order of the javascript executions, putting the RemoveQty() in the <a href="javascript:"> and adding the openNewPopupWindow to the "onClick=" section.
Has anyone run into this before and can anyone confirm that my guess as to why it functioned this way is correct?
Yours with curiosity,
Sylvan