We can have one event attached to multiple actions in javascript. I have facing problem in this scenario.
1. I am having first.jsp, second.jsp2. Both pages load one.js and two.js
3.In one.js, I am attaching document.attachEvent(“onkeydown”, functionOne).
4.In two.js, I am attaching document.attachEvent(“onkeydown”, functionTwo).
Now I am loading page first.jsp. In first.jsp i have a button when i click on it second.jsp is loaded as popup window, that means first.jsp is parent and second.jsp is popup and both have one.js and two.js loaded simultaneously and events attached.
Problem: (browser IE 6)
In parent (first.jsp), when I press a key, functionTwo is executed first and then functionOne.
In popup(second.jsp), when I press a key, functionOne is executed first and then functionTwo.
Questions:
1. when a event is attached to multiple functions then what is the priority by which they are called?
2.In the above problem, why the functions are executing reverse? Which is the correct scenario? how to rectify the problem?
I appreciate if some one can answer the above questions.