Results 1 to 10 of 10

Thread: How to make my code cross-browser compatible??

  1. #1
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to make my code cross-browser compatible??

    Hi everyone,
    Can anyone tell me how do I make my code cross-browser compatible because every piece of code I make only works in firefox(even not every version of firefox) and not in other browsers. Any ideas how I can make my code work in *almost all* browsers??
    Thanks for you patience reading this.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What code?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I meant everything I tried making with javascript(ajax chat, contact forms etc.)

  4. #4
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    only use features that are suported in *almost all* browsers.

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    There really is no set way to achieve this. In fact, unless you can test in all browsers, there is no way to be certain that whatever you do, thinking that it will make it cross browser will work.

    Most beginners like the idea of browser detection. This is virtually doomed to failure in some browsers because it is impossible to test for every browser out there and some will do their best to avoid detection.

    I, and many more experienced javascript coders like to use feature detection. You've seen that, it is like:

    Code:
    if (document.getElementById)
    var bob=document.getElementById('bober');
    This is a good way to go about it as we are basically asking the browser if it does this and then asking it to do it if it does.

    There is no real substitute for getting to know what sort of things this or that browser will do though. I don't think one's knowledge in this area could ever be complete but, the more you know, the better you are able to select the most universal sort of approach. It also helps you in being aware of what might cause a problem in one or more browsers so that you can provide code branches to handle these situations.

    If you keep your code as simple as possible and use feature detection, providing branches for browsers with various capabilities to follow if they need to, things can usually work out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    jscheuer1: unfortunately I neither have all the browsers except firefox nor do I know many objects in javascript to use object detection. Can you help me find out all the supported objects in browsers??

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I neither have all the browsers except firefox
    Get some more. A single browser isn't nearly enough to thoroughly test a page.
    Can you help me find out all the supported objects in browsers?
    QuirksMode helps. Alternatively, there's the good old-fashioned method: when one of your browsers complains that it can't find object X, it's pretty obvious that said browser doesn't support X.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Twey
    A single browser isn't nearly enough to thoroughly test a page.QuirksMode helps. Alternatively, there's the good old-fashioned method: when one of your browsers complains that it can't find object X, it's pretty obvious that said browser doesn't support X.
    I agree heartily with the above. I use Opera, FF, and IE and have plans to add others. I was using Konqueror but, the interface (cygwin) I had that allowed me to run it was too arcane for me to understand if I could and how to get the updates for Konq. I have plans to add other browsers and OS's. I'm careful with IE though, it really is a security nightmare, or at least a bad dream.

    quirksmode.org is a great resource, somebody should give that guy a medal.

    Also, when you get to a point where something isn't supported in a given browser, you can always Google the object and the browser, ex:

    IE addEventListener

    and it usually will find you the alternative, if any, used by that browser.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Umm.. what if you can't install any browsers??

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by shachi
    Umm.. what if you can't install any browsers??
    Then you first need a computer.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •