in my php application i have used onchange and onload javascript is working fine in IE but it is not working in other browsers eg:mozilla,chrome,flock

It would help to see the code. It's kind of hard to help debug code that you can not see :)

For the record tho. If it doesn't work in Mozilla and the other standards supporting browsers, it doesn't work.
IE is flawed, so some code that shouldn't work works, but a lot of code that should work doesn't work.

It's always best to create code that works in the standards supporting browsers first (Firefox/Opera/Chrome/etc...) and then apply fixes for the others (others being IE).
If you do it the other way around you'll go insane for sure :)

I did a bit of searching on the w3 website and found a javascript code which detects what browser you are using. So if it is javascript you are trying to use then the below code allows 2 separate codes to be used, 1 for Internet Explorer while the other js code is for any other browser. So the script is:

<script type="text/javascript">
var browser=navigator.appName;
if (browser="Microsoft Internet Explorer")
//Internet explorer code
} else {
//Code for any other browser

And as the comments show in the code box above, you can place separate code for Internet Explorer.

Note: Next time please try and post in the appropriate section as this thread currently has no reference to php other than that the javascript is been echo""; by php.

I would avoid coding to specific browsers, like you suggest.
It is far better to code to available objects, falling back on buggy code only if the standard method isn't available.

For example, to create an AJAX object. Rather than detect the browser and move on from there, like so:

var ajaxObject = null;
if (navigator.appName == "Microsoft Internet Explorer") {
  ajaxObject = new ActiveXObject("Msxml2.XMLHTTP");
else {
  ajaxObject  = new XMLHttpRequest();

You should check if the standard XMLHttpRequest object exists:

var ajaxObject = null;
if(window.XMLHttpRequest) {
  ajaxObject = new XMLHttpRequest();
else {
  ajaxObject = new ActiveXObject("Msxml2.XMLHTTP");

This way, if Microsoft ever catches up on standards, the buggy code will automatically be ignored.

This article has been dead for over six months. Start a new discussion instead.