Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

CSS/JS rollover issue on load

  • 08-06-2006 11:27am
    #1
    Registered Users, Registered Users 2 Posts: 3,514 ✭✭✭


    I have a little issue with the code below. When a user rolls over a link a description of the link should appear within a div just under it, however, on page load all the divs get displayed to the user. How can i change it so that on load nothing appears untill the user rolls over the links. Included is a screen shot of the problem. It's probably a fairly simple issue to resolve but there are a lot more able folk out there with regards to CSS/JS over myself.

    JS Code
    [html]
    <script language="JavaScript">
    function setVisibility(id, visibility) {
    document.all[id].style.display = visibility;
    }

    </script>
    <body >
    <a href='tutorial.php' onMouseOver="setVisibility('sub1', 'inline');" onMouseOut="setVisibility('sub1','none');">Tutorial Page</a><br>
    <a href='logout.php' onMouseOver="setVisibility('sub2', 'inline');" onMouseOut="setVisibility('sub2','none');">Logout</a><br>
    <div id="sub1">go place 1</div>
    <div id="sub2">go place 2</div>[/html]
    CSS Code
    sub1 {
    
    display: none;
    }
    
    sub2 {
    
    display: none;
    }#sub1 {
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-size: 12px;
        font-weight: bold;
        color: #FFFFFF;
        text-decoration: underline;
        position: absolute;
        left: 358px;
        top: 83px;
    
    
    }#sub2 {
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-size: 12px;
        font-weight: bold;
        color: #FFFFFF;
        text-decoration: underline;
        position: absolute;
        left: 358px;
        top: 83px;
    }
    


Comments

  • Registered Users, Registered Users 2 Posts: 3,594 ✭✭✭forbairt


    looks like its a problem with id's and classes ...

    your first bit of CSS code should include
    #sub1

    not just sub1 {display: none;}

    and similar for sub2 ...

    That said I've not verified that ...

    #sub1 { display: none; }
    #sub2 { display: none; }


  • Registered Users, Registered Users 2 Posts: 3,012 ✭✭✭BizzyC


    use the visibility attribute.
    set visibility:hidden for #sub1&2, and toggle them to visible when you want them displayed.


  • Registered Users, Registered Users 2 Posts: 3,514 ✭✭✭Rollo Tamasi


    i have attempted this code but it isn't working
    #sub2 {
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-size: 12px;
        font-weight: bold;
        color: #FFFFFF;
        text-decoration: underline;
        position: absolute;
        left: 358px;
        top: 83px;
         visibility: hidden;
        }
        #sub2:hover {
        position: absolute;
        visibility: visbile;    
        left: 358px;
        top: 83px;
    
    }
    


  • Registered Users, Registered Users 2 Posts: 3,594 ✭✭✭forbairt


    ignored my suggestion ?
    <html>
    <script type="text/javascript">
    function setVisibility(id, visibility) 
    { 
      if(document.getElementById)
      {
        x = document.getElementById(id);
        currentClass = x.className;
        x.setAttribute("style","display:"+visibility+";");
      }
    } 
    </script>
    <style type="text/css">
    
    #sub1 { display: none; background-color: #F00;}
    #sub2 { display: none; background-color: #00F;}
    
    </style>
    <body
    ><a href='tutorial.php' onMouseOver="setVisibility('sub1', 'inline');" onMouseOut="setVisibility('sub1','none');">Tutorial Page</a><br>
    <a href='logout.php' onMouseOver="setVisibility('sub2', 'inline');" onMouseOut="setVisibility('sub2','none');">Logout</a><br>
    <div id="sub1">go place 1</div>
    <div id="sub2">go place 2</div>
    </body>
    </html>
    


  • Registered Users, Registered Users 2 Posts: 3,514 ✭✭✭Rollo Tamasi


    error9 wrote:
    ignored my suggestion ?

    :) thanks

    i was wondering why your coding wasn't working but i forgot i was importing the syles from the external sheet as well as defining the styles within the page! wooops


  • Advertisement
Advertisement