|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi All,
I am new to the website design world. I really love it. But I have a problem about how to link my web page to a separate .js file. In my web page, I have 5 links. The problem I have is to use Javascript to make a rollover type of effect. I want to change fonts to 14px and blue color when the mouse hovers. And change it back when the mouse out. Here are my codes in the web page: -------------------------------------------------------------------- <li><a href="home.aspx" title="home">home</a></li> <li><a href="contactinfo.aspx" title="contactinfo">contactinfo</a></li> <li><a href="customerservice.aspx" title="customerservice">customerservice</a></li> <li><a href="feedback.aspx" title="feedback">feedback</a></li> <li><a href="myaccount.aspx" title="myaccount">myaccount</a></li> --------------------------------------------------------------------- Can anyone show me how to write a Javascript code into a separate file and make this work? I really appreciate your help. Thanks, Ian |
|
#2
|
||||
|
||||
|
Use css:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>rollover</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
ul {width:10em;}
a {
display:block;
font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size:0.8em;
color:#000;
background:#ccc;
}
a:hover {
font-size:1em;
color:#00f;
background:#ff9;
}
</style>
</head>
<body>
<ul>
<li><a href="home.aspx" title="home">home</a></li>
<li><a href="contactinfo.aspx" title="contactinfo">contactinfo</a></li>
<li><a href="customerservice.aspx" title="customerservice">customerservice</a></li>
<li><a href="feedback.aspx" title="feedback">feedback</a></li>
<li><a href="myaccount.aspx" title="myaccount">myaccount</a></li>
</ul>
</body>
</html>
__________________
At least 98% of internet users' DNA is identical to that of chimpanzees |
|
#3
|
||||
|
||||
|
No javascript required, just simple css
<style type="text/css"> .blueHover a:link { text-decoration: underline; color: black; } .blueHover a:hover { text-decoration: underline; color: blue; font-size:14px; } </style> -------------------------------------------------------------------- <li><a href="home.aspx" title="home" class="blueHover">home</a></li> --------------------------------------------------------------------- |
|
#4
|
|||
|
|||
|
Thanks Fang and mathursrishti. However, I want to learn how to use Javascript to make it happen. Maybe this is kind of stupid not to take the advantage of CSS. Do you guys can help me with that? I need to create a separate sheet to store Javascript and write some codes in HTML to read the code.
Thanks again, Ian |
|
#5
|
|||
|
|||
|
Please, can anyone show me how to use JavaScript to do this trick? I really appreciate your kindness.
Thanks, Ian |
|
#6
|
||||
|
||||
|
It is completely inappropriate to do something with JavaScript that should be done with CSS. If you were to do this with JavaScript then you'd need code to update the CSS for the "blueHover" class to the exact values that could have been entered into the CSS directly in the first place. You'd only really need to9 do that if you want visitors to be able to select between different actions on hovering over things based on a previous action and if you want that then a stylesheet switcher would be a more appropriate way of achieving it since almost all browsers have a stylesheet switcher built in and so you really only need to create a JavaScript equivalent for your visitors using Internet Explorer.
__________________
Stephen Free Computer Help, blog, forum Web design ebooks and software JavaScript scripts and tutorials |
|
#7
|
|||
|
|||
|
Unless it is a homework assignment? We don't do them for people.
__________________
If I have helped Quote:
|
|
#8
|
|||
|
|||
|
I searched everywhere for text change by using JavaScript but no help. CSS maybe a better resolution for me at this time I guess. Thanks all for the help.
|
|
#9
|
||||
|
||||
|
The usual method is to swap classes:
Code:
<li><a href="home.aspx" onmouseover="this.className='highlight';" onmouseout="this.className='normal';" title="home">home</a></li>
__________________
At least 98% of internet users' DNA is identical to that of chimpanzees |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|