Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macintosh MSIE Mac won't use my javascript for display: none or block.

    I don't know if this is just an issue with IE for Mac or if the other browsers are just being forgiving of some oversight on my part. Can someone shed some light on this for me please?

    The code is super-simplistic, I think...

    Code:
    <script language="javascript">
    function showElement(tagID) {
    var welcome = document.getElementById('welcome');
    var bio = document.getElementById('bio');
    var media = document.getElementById('media');
    var contact = document.getElementById('contact');
    var myTag = document.getElementById(tagID);
    welcome.style.display = "none";
    bio.style.display = "none";
    media.style.display = "none";
    contact.style.display = "none";
    if (myTag.style.display == "none") {
    myTag.style.display = "block";
    }
    };
    </script>
    ...activated by this...

    Code:
    <a class="navlink" onMouseOver="javascript:showElement('welcome')"  >|Welcome|</a>
    <a class="navlink" onMouseOver="javascript:showElement('bio')"  >|Bio|</a>
    <a class="navlink" onMouseOver="javascript:showElement('media')"  >|Media|</a>
    <a class="navlink" onMouseOver="javascript:showElement('contact')"  >|Contact|</a>
    ...and the css sheet has, among other things, "display: block;" on for the "welcome" div and "display: none;" on the rest of them.

    It looks like it should work to me, and it does, on most things. Mac IE is the only problem I've had so far. Can anyone either help me fix it, or tell me that IE Mac is just being buggy, or if I'm completely useless and "go away"?

    Thanks a lot, I appreciate it.

  • #2
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Come on now...

    I have 0 VIEWS and I'm on page three. *sigh*. That's kinda no good. No one is even going to read my problem?

    I usually hate bumps, but... *bump*

    sorry

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    if (myTag.style.display == "none") {
    If there is no style set inside your tag, there is no style to be found. If you have set the CSS using an embeded or external you should use something else to get the CSS attributes.

    Well, anyway, you may also try this:

    if ((myTag.style.display=='')||(myTag.style.display == "none")) {

    or

    if ((myTag.style.display==null)||(myTag.style.display == "none")) {

    And: use <script type="text/JavaScript"> instead of <script language="javascript">. The latest is deprecated.
    Last edited by Kor; 04-13-2005 at 04:31 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i didn't show the code for the divs,, since basically they're <div id=blah>content</div> with the style stuff in the style.css sheet.

    i will try the script = script type="text/JavaScript" though, thanks for the tip about deprecation.

    display refers to the css property display:

    Code:
    #divname {display: none;
    }
    for example.

    the display is never null, it's either "none" or "block". This works in all other browsers. an example is at www.mitchfactor.com

    thanks
    Last edited by BuckoSama; 04-14-2005 at 05:45 AM.

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I repeat. If the CSS property is set otherwise than locally, inside the tag, that means there is no style="attribute:value" so that object.style.attribute='' has no meaning.

    If the CSS attributes are set embeded or external, to get the style properties you have to use other methods (IE and Moz have different behaviuor on that):

    PHP Code:
    function getStyle(el,styleProp)
    {
        var 
    document.getElementById(el);
        if (
    window.getComputedStyle)//Mozilla, DOM compliant
            
    var window.getComputedStyle(x,null).getPropertyValue(styleProp);
        else if (
    x.currentStyle)//IE
            
    var = eval('x.currentStyle.' styleProp);
        return 
    y;

    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts

    square bracket notation

    Quote Originally Posted by Kor
    var y = eval('x.currentStyle.' + styleProp);
    var y = x.currentStyle[styleProp];
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    eerrr yes, sorry.... I have copy/paste the code from one of my elder test pages... I now also avoid eval() method...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #8
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    On the other hand, maybe you don't need that code. I insist, the below code should also be used in your case

    if ((myTag.style.display=='')||(myTag.style.display == 'none')) {

    the '' is not a double quote, there are 2 simple quotes there...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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