sheraz Posted September 26, 2009 Share Posted September 26, 2009 hi, i am new to html. i have write code for image roll over. but it is not working at all. please guide me what the problem is? here is the code. <html> <body> <a href="#" onMouseOver="document.image.src='navbar_home_rollover.jpg';return true" onMouseOut = "document.image.src='navbar_home.jpg';return true"> <image src="navbar_home.jpg"></a> </body></html> :'( Quote Link to comment Share on other sites More sharing options...
Russia Posted September 26, 2009 Share Posted September 26, 2009 Here you go: <script language="Javascript"> <!-- //Simple Switch Image Russia Inc. //Made By Russia of PHPFreaks.com if (document.images) { button1 = new Image button2 = new Image button1.src = 'navbar_home.jpg' button2.src = 'navbar_home_rollover.jpg' } //--> </script> <a href="link.php" onmouseover="document.rollover.src=button2.src" onmouseout="document.rollover.src=button1.src"> <img src="navbar_home.jpg" name="rollover" border="0"></a> Quote Link to comment Share on other sites More sharing options...
CarbonCopy Posted September 27, 2009 Share Posted September 27, 2009 Actually, I wouldn't use JavaScript at all (The less you use it the better). Something like this would work a { width:100px; height:40px; background:url('images/button_1.jpg'); } a:hover { background:url('images/button_1_hover.jpg'); } a span { display:none; } <a href='http://google.com'><span>Link name</span></a> Quote Link to comment Share on other sites More sharing options...
Russia Posted October 3, 2009 Share Posted October 3, 2009 Thing is he might not want it for all. Just for one link. Quote Link to comment Share on other sites More sharing options...
CarbonCopy Posted October 4, 2009 Share Posted October 4, 2009 Yes, then you would use ids #menu-1 { width:100px; height:40px; background:url('images/button_1.jpg'); } #menu-1:hover { background:url('images/button_1_hover.jpg'); } #menu-1 span { display:none; } <a href='http://google.com' id="menu-1"><span>Link name</span></a> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.