Hi,
Last week i was coding for a website which was totally dynamic using jsp and spring framework, I wrote many JavaScript functions to perform dynamic things throughout the website. Now, the site worked perfectly in internet explorer 8 and other old ie versions. Now my task was to make it compatible for other browsers including mozilla, opera and google chrome. I managed to make it work in opera and google chrome but failed to execute some modules in mozilla firefox !!!
Here's where i failed
-> document.getElementById('myid').click()
This function failed in mozilla and worked fine in other ie versions
Last week i was coding for a website which was totally dynamic using jsp and spring framework, I wrote many JavaScript functions to perform dynamic things throughout the website. Now, the site worked perfectly in internet explorer 8 and other old ie versions. Now my task was to make it compatible for other browsers including mozilla, opera and google chrome. I managed to make it work in opera and google chrome but failed to execute some modules in mozilla firefox !!!
Here's where i failed
-> document.getElementById('myid').click()
This function failed in mozilla and worked fine in other ie versions
I solved it using
var oEvent = document.createEvent("MouseEvents");oEvent.initMouseEvent("click", true, true,window, 1, 1, 1, 1, 1, false, false, false, false, 0, target);target.dispatchEvent( oEvent );
I managed to make click event dynamic using javascript functions which worked for me in both ie and mozilla
-> Event propagation in dynamic check boxes created using DOM
var element3 = document.createElement("input");cell3.setAttribute("align","center");element3.type = "checkbox";element3.id=myid;element3.onclick = function() { checkChangedValue('mytest',nameid, gname, e) };
The above mechanism does not work in mozilla firefox but it works perfectly in internet explorer.
I resolved it using
element3.addEventListener("click", function(e) {checkChangedValue('myname',ids, gname, e);}, true);
This works perfectly in both browsers, i had other issues with mozilla firefox but its a long list to discuss, it took around 22 hours for me to make this whole website compactible in mozilla firefox and internet explorer......Feeling like have won a war !!! One day, all browsers will follow same scripting all ower, m waiting for that day to come...
Cheers all,
Ujjwal
No comments:
Post a Comment