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 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2006
    Posts
    70
    Thanks
    9
    Thanked 0 Times in 0 Posts

    CSS Class & Javascript

    Hi there, i am trying to add a CSS to some Javascript and it isnt working. Can anyone suggest where I am going wrong?
    JAVASCRIPT
    Code:
    <script language="JavaScript">
    <!-- Begin
    if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
    
    var url="http://www.example.com";
    var title="Example";
    
    document.write('<a class=""BOTTOM"" href="javascript:window.ext');
    document.write('ernal.AddFavorite(url,title);" ');
    document.write('onMouseOver=" window.status=');
    document.write("'Bookmark our website!'; return true ");
    document.write('"onMouseOut=" window.status=');
    document.write("' '; return true ");
    document.write('">Bookmark this Site!</a>');
    }
    else {
    var msg = "Don't forget to bookmark us!";
    if(navigator.appName == "Netscape") msg += " (CTRL-D)";
    document.write(msg);
    }
    // End -->
    </script>
    CSS
    Code:
    a.BOTTOM:link { color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; text-decoration: none; }
    a.BOTTOM:visited { color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; text-decoration: none; }
    a.BOTTOM:hover { color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; text-decoration: none; }
    a.BOTTOM:active { color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; text-decoration: none; }
    Cheers
    Mal

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    No javascript browser detection needed. Just add this where you want the link to appear. IE will get the link, other browsers will get your message.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <style type="text/css">
    a.bottom {
    color:#CCC;
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:13px;
    text-decoration:none;
    }
    </style>
    </head>
    
    <body>
    <!--[if IE]>
    <a class="bottom" href="#" onclick="window.external.AddFavorite('http://www.example.com','Example');return false;" onmouseover="window.status = 'Bookmark our website!';return true" onmouseout="window.status = '';return true">Bookmark this site!</a>
    <![endif]-->
    <!--[if !IE]>-->
    Don't forget to bookmark us! (CTRL-D)
    <!--<![endif]-->
    </body>
    </html>
    Last edited by _Aerospace_Eng_; 02-01-2007 at 06:19 AM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    The reason it didn't work was because you use class=""BOTTOM"" which the browser reads only as class="" and the remaining text ignored. You must be getting used to ASP coding.
    Code:
    document.write('<a class=""BOTTOM"" href="javascript:window.ext');


  •  

    Posting Permissions

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