Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

compatibility questions

VB NewbieVB Newbie Posts: 206Member
Hi,

As a newbie I have some basic questions.
1) Are php script and Javascript compatible with both IE and Netscape?
2) How to inform a user (with an allertbox) that he is NOT using IE and viewing the website may be a problem?
3) Any additional advise is welcome!

Thanks,

VB Newbie


Comments

  • WeirdofreakWeirdofreak Posts: 439Member
    : 1) Are php script and Javascript compatible with both IE and Netscape?
    If by PHP script you mean PHP, then no. In fact, whatever you mean by PHP script, no, because Javascript differs radically. They both (as well as practically every other browser out there) support it, but when you start trying to do particularly complex stuff, you need to check which one the user's browser supports. They all do the basic stuff, including checking which method is supported, the same though, which is lucky.

    PHP isn't technically supported by either. It's server-side, so the browsers don't see it. Of course, if they did have to interpret it themselves, there'd be massive incompatibility problems, so consider yourself lucky.

    : 2) How to inform a user (with an allertbox) that he is NOT using IE and viewing the website may be a problem?
    If you have to do that, you need to re-write the code. There's very little that IE can do that the other browsers can't, except for spreading a virus. :-)

    A very good site for sorting out browser incompatibilities is http://www.quirksmode.org, it's very useful for looking up the equivalent for another browser.

    : 3) Any additional advise is welcome!
    I'm not entirely sure what sort of advice you're looking for here, but I'll try:
    - Keep your code clean. Indent, keep different statements on different lines. You'll regret it in a month's time if you don't.
    - NEVER use a browser detect. Most (decent) browsers allow you to change your user-agent, so that you look like another browser. Plus it alienates the little people if you have one block of code for IE and one for Mozilla/Netscape, Opera for instance supports some features of each. Instead, use object detection (if (genericFunction) {/*it's supported*/}), but be careful not to abuse that either. Don't say anything like if (document.all) { /*do IE stuff*/ }, that's almost as bad as traditional browser detects.
    - Name variables intelligently. The range of it should be directly proportional to the length of the name - if you'll be using it all through a very long script, give it as descriptive a name as you can, if it's just for a short loop, calling it i will do fine.

    Vote D.

  • JonathanJonathan Posts: 2,914Member
    : : 1) Are php script and Javascript compatible with both IE and Netscape?
    : If by PHP script you mean PHP, then no. In fact, whatever you mean by PHP script, no, because Javascript differs radically. They both (as well as practically every other browser out there) support it, but when you start trying to do particularly complex stuff, you need to check which one the user's browser supports. They all do the basic stuff, including checking which method is supported, the same though, which is lucky.
    :
    : PHP isn't technically supported by either. It's server-side, so the browsers don't see it. Of course, if they did have to interpret it themselves, there'd be massive incompatibility problems, so consider yourself lucky.
    :
    Executive summary: PHP has nothing to do with the web browser whatsoever, JavaScript has annoying subtle (and sometimes not so subtle) differences between browsers.

    : : 3) Any additional advise is welcome!
    : I'm not entirely sure what sort of advice you're looking for here, but I'll try:
    : - Keep your code clean. Indent, keep different statements on different lines. You'll regret it in a month's time if you don't.
    : - NEVER use a browser detect. Most (decent) browsers allow you to change your user-agent, so that you look like another browser. Plus it alienates the little people if you have one block of code for IE and one for Mozilla/Netscape, Opera for instance supports some features of each. Instead, use object detection (if (genericFunction) {/*it's supported*/}), but be careful not to abuse that either. Don't say anything like if (document.all) { /*do IE stuff*/ }, that's almost as bad as traditional browser detects.
    : - Name variables intelligently. The range of it should be directly proportional to the length of the name - if you'll be using it all through a very long script, give it as descriptive a name as you can, if it's just for a short loop, calling it i will do fine.
    :
    If we're handing out good programming practice advice...
    - Comment your code! Comment it lots, and never forget to comment it. That way, you and anyone else who works on it will have a clue what it does a few months down the line.
    - If you're writing server side code (e.g. PHP), think about security issues (e.g. SQL Injection if you're using a database, path hijacking if you're fopen'ing stuff, etc.)

    : Vote D.
    :
    D?

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • WeirdofreakWeirdofreak Posts: 439Member
    : D?

    My sig. There's an 'election' going on at a board I post at, so I'm spreading pro-D propaganda everywhere in the hope that somebody will somehow work out what I'm talking about and vote for him. Long shot, but I figured it's worth a try.
    ---
    Vote D.

Sign In or Register to comment.