Browser compatibility

Discussion in 'Javascript' started by jfancy-Transport Canada, May 26, 2005.

  1. I need this translated so it can be used in Mozilla, and in Opera. Two
    seperate ways of code is fine. Thanks!

    Justin

    -------------------------------------------------------------------

    <html>
    <head>

    </head>
    <body>
    <h1>Hello there</h1>
    <h2>Test</h2>
    anything.

    <input type="button" onclick="resizeBodyText(2, 'n')" value="Font +" >
    <input type="button" onclick="resizeBodyText(-2, 'n')" value="Font -" >

    <input type="reset" onclick= "resizeBodyText(0, 'y')">

    <script type="text/javascript">
    //-------------------------------------------------


    var current = parseInt(getCookie("fontFactor"))
    if (isNaN(current))
    current= 0;

    resizeBodyText(current, "n")
    function resizeBodyText(factor, reset)
    {
    if (reset=="y")
    factor= (current * -1);

    window.alert(current + " " + factor)
    //------------------------------------------------
    var a = document.all;
    var s = '';
    current += factor;

    if (current < 0)
    current = 0;
    else
    for (var i = a.length-1; i >0;i--)
    {
    s=a.currentStyle.fontSize+'';
    s=Right(s,2);
    a.style.fontSize = parseInt(a.currentStyle.fontSize)+factor+s;
    }
    setCookie("fontFactor", current)
    }

    //-----------------------------------------------
    function Right(str, n) {
    if (n <= 0)
    return "";
    else if (n > String(str).length)
    return str;
    else {
    var iLen = String(str).length;
    return String(str).substring(iLen, iLen - n);
    }
    }
    //-------------------------------------------------
    function getCookie(name) {
    var dc = document.cookie;
    var index = dc.indexOf(name + "=");
    if (index == -1) return null;
    index = dc.indexOf("=", index) + 1; // first character
    var endstr = dc.indexOf(";", index);
    if (endstr == -1) endstr = dc.length; // last character
    return unescape(dc.substring(index, endstr));
    }
    function setCookie(name, value)
    {
    document.cookie= name + "=" + escape(value);
    }

    </script>
    </body>
    </html>
    jfancy-Transport Canada, May 26, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Blum

    Re: Non IE browser compatibility.

    Peter Blum, Feb 13, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    500
    Chad Z. Hower aka Kudzu
    Feb 16, 2004
  2. =?Utf-8?B?RzI=?=

    Browser Compatibility Issues

    =?Utf-8?B?RzI=?=, May 16, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    420
    Darren Clark
    May 17, 2004
  3. ms
    Replies:
    3
    Views:
    422
    Steven Cheng[MSFT]
    Feb 2, 2005
  4. Paul Mason

    Formatting and browser compatibility

    Paul Mason, May 19, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    414
    Paul Mason
    May 20, 2005
  5. Goffin
    Replies:
    2
    Views:
    624
    Goffin
    Aug 5, 2005
Loading...

Share This Page