...

View Full Version : CSS Class & Javascript



malhyp
02-01-2007, 06:06 AM
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


<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


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

_Aerospace_Eng_
02-01-2007, 07:10 AM
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.

<!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>

glenngv
02-02-2007, 10:17 PM
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.

document.write('<a class=""BOTTOM"" href="javascript:window.ext');



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum