cs.punk Posted March 26, 2009 Share Posted March 26, 2009 Ok I understand PHP basically... I just want to know if someone can explain this to me: //Preload images if (document.images) {login_on = new image login = new image //what are these 'new image' for? A varible //assigned to another one? login_on.src = "images/login_on.jpg" login.src = "images/login.jpg" } function chgImg(imgField,imgState) {document[imgField].src = "images/" + imgField + imgState + ".jpg" } Thats the script right, <a href="login.php" onmouseover="chgImg('login','_on')" onmouseout="chgImg('login','')"> <img src="images/login.jpg" width="120" height="62" border="0"name="login" /> </a> How could I write this script so that I can call on the externel script (the first one) for all my image roll overs, not just for the login button? Link to comment https://forums.phpfreaks.com/topic/151246-image-rollover-i-am-new-to-js-please-explain-me-something/ Share on other sites More sharing options...
corbin Posted March 26, 2009 Share Posted March 26, 2009 You could have an array of image paths and just loop through it. Link to comment https://forums.phpfreaks.com/topic/151246-image-rollover-i-am-new-to-js-please-explain-me-something/#findComment-794525 Share on other sites More sharing options...
N1CK3RS0N Posted March 28, 2009 Share Posted March 28, 2009 Theres a much easier way to do mouseover image changes without javascript. HTML <td class="nav_01"> <a href="#"><span class="nav-hide">Home</span></a> </td> CSS .nav_01 a { width: 80px; height: 45px; background: url(../images/nav_01.png); background-repeat: no-repeat; display: block; margin: 0 auto; } .nav_01 a:hover { background: url(../images/nav_over_01.png); background-repeat: no-repeat; } .nav-hide { display:none; } Link to comment https://forums.phpfreaks.com/topic/151246-image-rollover-i-am-new-to-js-please-explain-me-something/#findComment-795590 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.