943,910 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 496
  • PHP RSS
Nov 6th, 2008
0

help

Expand Post »
in my php application i have used onchange and onload javascript function.it is working fine in IE but it is not working in other browsers eg:mozilla,chrome,flock
Reputation Points: 3
Solved Threads: 2
Junior Poster
kings is offline Offline
107 posts
since Nov 2007
Nov 6th, 2008
0

Re: help

this would be a javascript question. does this relate to php at all?

please give more details.
Last edited by kkeith29; Nov 6th, 2008 at 1:27 am.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Nov 6th, 2008
0

Re: help

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
Reputation Points: 93
Solved Threads: 70
Posting Pro
Atli is offline Offline
526 posts
since May 2007
Nov 6th, 2008
0

Re: help

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:
javascript Syntax (Toggle Plain Text)
  1. <script type="text/javascript">
  2. var browser=navigator.appName;
  3. if (browser="Microsoft Internet Explorer")
  4. {
  5. //Internet explorer code
  6. } else {
  7. //Code for any other browser
  8. }
  9. </script>
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.
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007
Nov 6th, 2008
0

Re: help

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:
javascript Syntax (Toggle Plain Text)
  1. var ajaxObject = null;
  2. if (navigator.appName == "Microsoft Internet Explorer") {
  3. ajaxObject = new ActiveXObject("Msxml2.XMLHTTP");
  4. }
  5. else {
  6. ajaxObject = new XMLHttpRequest();
  7. }
You should check if the standard XMLHttpRequest object exists:
javascript Syntax (Toggle Plain Text)
  1. var ajaxObject = null;
  2. if(window.XMLHttpRequest) {
  3. ajaxObject = new XMLHttpRequest();
  4. }
  5. else {
  6. ajaxObject = new ActiveXObject("Msxml2.XMLHTTP");
  7. }
This way, if Microsoft ever catches up on standards, the buggy code will automatically be ignored.
Last edited by Atli; Nov 6th, 2008 at 4:35 am.
Reputation Points: 93
Solved Threads: 70
Posting Pro
Atli is offline Offline
526 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: need rotating div display, preferably in PHP
Next Thread in PHP Forum Timeline: TEACH PHP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC