Interesting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jfancy-Transport Canada

    Interesting

    I need this code to work for all the IE, Netscape, Opera, and Mozilla
    versions. To go about doing this, it is a definite task. I have it
    working in IE(all versions) but it will not increment or decrement the
    font size in any other browsers. Any suggestions?


    <html>
    <head>

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

    <input type="submit" onclick="resize BodyText(2, 'n')" >
    <input type="submit" onclick="resize BodyText(-2, 'n')" >
    <button type="submit" onclick= "resizeBodyText (0, 'y')" >


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


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

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

    window.alert(cu rrent + " " + factor)
    //------------------------------------------------
    if (document.all) {
    var a = document.all;
    var s = '';
    current += factor;
    var test = "IE!"
    if (current < 0)
    current = 0;
    else
    for (var i = a.length-1; i >0;i--)
    {
    s=a[i].currentStyle.f ontSize+'';
    s=Right(s,2);
    a[i].style.fontSize = parseInt(a[i].currentStyle.f ontSize)+factor +s;
    }
    setCookie("font Factor", current)
    }
    else if (document.getEl ementsByTagName ) {
    var a = document.getEle mentsByTagName( "*");
    var s = '';
    current += factor;
    var test = "Netscape 6+!"
    if (current < 0)
    current = 0;
    else
    for (var i = a.length-1; i >0;i--)
    {
    s=a[i].style.fontSize +'';
    s=Right(s,2);
    a[i].style.fontSize = parseInt(a[i].style.fontSize )+factor+s;
    }
    setCookie("font Factor", current)
    }
    else if (document.layer s) {
    var a = document.layers ("*");
    var s = '';
    current += factor;
    var test = "Netscape OLD 4!";
    if (current < 0)
    current = 0;
    else
    for (var i = a.length-1; i >0;i--)
    {
    s=a[i].style.fontSize +'';
    s=Right(s,2);
    a[i].style.fontSize = parseInt(a[i].style.fontSize )+factor+s;
    }
    setCookie("font Factor", current)
    }
    window.alert(te st)
    }


    //-----------------------------------------------
    function Right(str, n) {
    if (n <= 0)
    return "";
    else if (n > String(str).len gth)
    return str;
    else {
    var iLen = String(str).len gth;
    return String(str).sub string(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.sub string(index, endstr));
    }
    function setCookie(name, value)
    {
    document.cookie = name + "=" + escape(value);
    }

    </script>

    </body>
    </html>

  • Lee

    #2
    Re: Interesting

    jfancy-Transport Canada said:[color=blue]
    >
    >I need this code to work for all the IE, Netscape, Opera, and Mozilla
    >versions. To go about doing this, it is a definite task. I have it
    >working in IE(all versions) but it will not increment or decrement the
    >font size in any other browsers. Any suggestions?[/color]

    Most browsers already have a menu option and/or shortcut key to
    increment/decrement the font size. Why add another thay may or
    may not work?

    Comment

    • jfancy-Transport Canada

      #3
      Re: Interesting

      Don't ask me, ask Transport Canada.

      Comment

      • Randy Webb

        #4
        Re: Interesting

        jfancy-Transport Canada wrote:[color=blue]
        > Don't ask me, ask Transport Canada.
        >[/color]

        But you are representing them, you are supposedly the competent
        authority on the matter, it is *your* duty to explain to Transport
        Canada that its a stupid idea.

        Please read the group FAQ, thoroughly.

        --
        Randy
        comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
        Answer:It destroys the order of the conversation
        Question: Why?
        Answer: Top-Posting.
        Question: Whats the most annoying thing on Usenet?

        Comment

        • jfancy-Transport Canada

          #5
          Re: Interesting

          Believe me, I already have, but I am a student and I don't think I have
          that kind of authority right now!

          So, any suggestions or ?

          Comment

          • Random

            #6
            Re: Interesting



            Comment

            • Dr John Stockton

              #7
              Re: Interesting

              JRS: In article <1117630802.552 151.322830@o13g 2000cwo.googleg roups.com>
              , dated Wed, 1 Jun 2005 06:00:02, seen in news:comp.lang. javascript,
              jfancy-Transport Canada <justinfancy@gm ail.com> posted :[color=blue]
              >Believe me, I already have, but I am a student and I don't think I have
              >that kind of authority right now!
              >
              >So, any suggestions or ?[/color]

              For proper quoting when using Google for News :-
              Keith Thompson wrote in comp.lang.c, message ID
              <lnwtuhfy7d.fsf @nuthaus.mib.or g> :-
              If you want to post a followup via groups.google.c om, don't use
              the "Reply" link at the bottom of the article. Click on "show
              options" at the top of the article, then click on the "Reply" at
              the bottom of the article headers.

              Since that is what the experts in this newsgroup prefer to read, it will
              be to your advantage to comply.

              You have already been told to read the FAQ.

              --
              © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
              <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
              <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
              <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

              Comment

              Working...