SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    Fort Lauderdale
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question div tag in IE && NS

    I'm trying to figure out how Netscape references objects.

    in IE I have a:
    div id=foo
    then my jscript:
    foo.style.visibility = "visible";

    i thougth netscape would be:
    document.foo.style.visibility = "show";
    thats not the case, anyone?

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Netscape 4 does not have a style property.To set any style property of a div you have to use some type of api function like this...

    Code:
    function getStyle(idname){
    	if(document.getElementById){
    		return document.getElementById(idname).style;
    	}else if(document.all){
    		return document.all[idname].style;
    	}else if(document.layers){
    		return document.layers[idname];
    	}
    }
    function showVis(idname){
    	getStyle(idname).visibility = "visible";
    }
    
    showVis("divIdName");
    travis

  3. #3
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in IE I have a:
    div id=foo
    then my jscript:
    foo.style.visibility = "visible";

    i thougth netscape would be:
    document.foo.style.visibility = "show";
    thats not the case, anyone?
    Both those code snippets demonstrate the Microsoft-proprietary document.all API.


    In netscape 4.x, you would need to use the Netscape-proprietary document.layers API :
    Code:
    document.layers["foo"].visibility=(whatever)
    N.B. Netscape 4.x uses "hide" and "show" rather than "hidden" and "visible"

    For Netscape 6/7, Mozilla, and the shiny new Opera 7 beta, use the W3C DOM:
    Code:
    document.getElementByID("foo").style.visibility=(whatever)
    This code will also work in IE (version 5.5 onwards, at least, maybe 5.0 too)

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    Fort Lauderdale
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Thanks a lot, exactly what I needed. Its kinda cool when your site works in most browsers.

  5. #5
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's the good thing about standards


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
  •