Results 1 to 5 of 5

Thread: Javascript - IE - All....

  1. #1

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Javascript - IE - All....

    Hi,

    I have the following in html:
    Code:
    <span class="BArea"><span class="b1"><a href="#" onClick="SwitchMenu('TestMenu',document); return false;">A Link</a></span></span>
    <div class="MenuArea" Name="TestMenu">
    <span class="BArea"><span class="b1"><a href="#">Menu Link</a></span></span>
    <span class="BArea"><span class="b1"><a href="#">Another Link</a></span></span>
    </div>
    I can't seem to reference the TestMenu tag/item at all using :
    Code:
    document.all.item(TestMenu).visibility = true;
    Any ideas what I'm doing wrong?


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  2. #2
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    I don't think you need to use all (which is IE only by the way), you should just be able to do it like this:

    document.TestMenu.style.visibility = 'visible';

    Or if you want to use IDs:

    <div id="elementId">

    document.getElementById('elementId').style.visibility = 'visible';

  3. #3

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    IE6

    Hi Rick,

    Thanks. Still didn't work tho

    I found in my Javascript book a chunk of code to print out the properties to a debug window. And I couldn't find style or visibility.

    After a bit of experimentation:
    function SwitchMenu (mnuName,d)
    {
    // listPropertyNames(mnuName.currentStyle);
    debug('Class : ' + mnuName.currentStyle.visibility);
    // debug(mnuName + ' ' + mnuName.innerHTML);
    /* if (browser.isIE){
    mnuName.style.visibility = !mnuName.style.visibility;
    } else if (browser.isNN) {

    }
    */
    }
    This seemed to print out what I needed.


    So as a quick question -
    Does this mean older browsers are different????


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  4. #4

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    Just to let you know. The following appears to work properly in IE6... SP1....

    Code:
    function SwitchMenu (mnuName,d)
    {
    	if (mnuName.currentStyle.visibility=='hidden')
    	{ 
    		mnuName.style.visibility="visible";
    	} else { 
    		mnuName.style.visibility="hidden"; 
    	}
    }
    I have to use current style to view and style to set or it doesn't work.

    Weird??


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  5. #5
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Originally posted by Ecniv

    So as a quick question -
    Does this mean older browsers are different????
    Most browsers have a different implementation of JavaScript, HTML, XML etc. but if you code to standards most times it will work the same in all the modern browsers. And usually if you can get things working in Mozilla it will work in all the other browsers too, esp for CSS.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width