Script help for mulitple browsers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hellays
    New Member
    • Dec 2009
    • 2

    Script help for mulitple browsers

    Hi everyone
    I know this has probably been asked a million times before but I have been searching the net for hours and have not found a solution so I am hoping one of you clever people will be able to help me. PLEASE!!

    I am using this snow fall script http://www.dynamicdrive.com/dynamicindex3/rain.htm

    It works perfectly in IE but not in Firefox or Safari.

    Anyone have any idea how to help? I am not the best with the techno speak so not too complicated if at all possible!

    Thank you so much to anyone who can help me out!
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    this script is not cross browser compatible (as far as I can tell from the first glance) you’d need to replace the used IE proprietary properties by something, that is able to read either ways.

    Comment

    • hellays
      New Member
      • Dec 2009
      • 2

      #3
      Thanks for your reply, sorry to be so thick but do you know how I do this? I have no idea!!
      Thanks

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        basicly you have to do a conditional block, where you loop through all (mostly 2) known properties to get the value you want.

        ex. (the properties may not be correct, just pulling from memory)
        Code:
        // always start with the ECMAScript or W3C standard
        if (window.clientWidth)
        {
            var width = window.clientWidth;
        }
        // then test IE proprietary features
        else if (window.screenX)
        {
            var width = window.screenX;
        }
        // throw error in case you’ve forgotten something
        else
        {
            throw new Error("Could not determine browser width.");
        }
        it may well be that there are such crossbrowser functions are already out there (e.g. there is a bunch of solutions for event handling)

        Comment

        Working...