Results 1 to 5 of 5

Thread: document.all and Firefox problems

  1. #1
    Join Date
    Nov 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default document.all and Firefox problems

    Hi

    I have the following JavaScript which does not work in Firefox, could anyone advise me how to get this to work. Works fine in IE.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <script type=text/javascript>
    function toggleT(_w,_h) {
    if (document.all) { // is IE
    if (_h=='s') eval("document.all."+_w+".style.visibility='visible';");
    if (_h=='h') eval("document.all."+_w+".style.visibility='hidden';");
    } else { // is NS?
    if (_h=='s') eval("document.layers['"+_w+"'].visibility='show';");
    if (_h=='h') eval("document.layers['"+_w+"'].visibility='hide';");
    }
    }
    </script>
    </head>
    <body>

    <form>
    Property Type ? (moving from)*<br />
    <input name="propertyType" type="radio" value="House" onClick="toggleT('divt1','h')" />House&nbsp;
    <input name="propertyType" type="radio" value="Flat" onClick="toggleT('divt1','s')"/>Flat&nbsp;
    <span id="divt1" style="visibility:hidden;position:relative;top:0;left:0">
    <input type="text" size="1" on />&nbsp;Floor</span>
    </form>
    </body>
    </html>

    Any input would be much app.
    Thanks in advance.

    Mark

  2. #2
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    Code:
    function toggleT(_w,_h) {
    if (document.all) { // is IE
    if (_h=='s') eval("document.all."+_w+".style.visibility='visible';");
    if (_h=='h') eval("document.all."+_w+".style.visibility='hidden';");
    } else { // is NS?
    if (_h=='s') eval("document.layers['"+_w+"'].visibility='show';");
    if (_h=='h') eval("document.layers['"+_w+"'].visibility='hide';");
    }
    }
    you dont need eval:
    Code:
    function toggleT(_w,_h) {
    if (document.all) { // is IE
    if (_h=='s') document.all._w.style.visibility='visible';
    if (_h=='h') document.all._w.style.visibility='hidden';
    } else { // is NS?
    if (_h=='s') document.layers[_w].visibility='show';
    if (_h=='h') document.layers[_w].visibility='hide';
    }
    }
    Last edited by Master_script_maker; 04-21-2008 at 07:45 PM. Reason: Mistake in javascript
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  3. #3
    Join Date
    Nov 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi
    Thanks for your input but that did not work for Firefox, I have read that document.all is not supported in any other browsers than IE and it should be replaced with getelementbyID, is this script slavagable or should I bin it ?

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by Master_script_maker View Post
    you dont need eval:
    Code:
    function toggleT(_w,_h) {
    if (document.all) { // is IE
    if (_h=='s') document.all._w.style.visibility='visible';
    if (_h=='h') eval("document.all._w.style.visibility='hidden';
    } else { // is NS?
    if (_h=='s') document.layers[_w].visibility='show';
    if (_h=='h') document.layers[_w].visibility='hide';
    }
    }
    you either forgot to remove that eval or you forgot to complete it.
    Code:
    eval("document.all._w.style.visibility='hidden'");

  5. #5
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    thanks i meant to remove it.
    cracken, does the _w variable contain a name?
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

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
  •