| | |
JS Rollover in Firefox
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: May 2008
Posts: 27
Reputation:
Solved Threads: 0
I am pretty new with javascript, and I am making a page that has divs that change an image when rolled over. It works in Live View in Dreamweaver, and in Safari (couldn't test in IE because I'm on a Mac), but not in Firefox.
Here's what I got in the Head section:
And in the body:
You can see the whole source at www.samscookiejar.com ( my wife's bakery. Page is still under major construction)
Here's what I got in the Head section:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script type="text/javascript"> function swapImage(image) { bakeryImage.src=image; } </script>
And in the body:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<div class="bodyInner"> <div class="bodyInner_Left"> <div class="menuItem" onmouseover="swapImage('images/foodPix/bread.jpg')">Bread</a></div> <div class="menuItem" onmouseover="swapImage('images/foodPix/pastries.jpg')">Pastries</div> <div class="menuItem" onmouseover="swapImage('images/foodPix/cookies.jpg')">Cookies</div> <div class="menuItem" onmouseover="swapImage('images/foodPix/cake.jpg')">Cakes</div> <div class="menuItem" onmouseover="swapImage('images/foodPix/tea.jpg')">Tea & Coffee</div> </div> <div class="bodyInner_Right"><img src="images/foodPix/cookies.jpg" width="730" height="469" name="bakeryImage" id="bakryImage" /></div> </div> </div>
You can see the whole source at www.samscookiejar.com ( my wife's bakery. Page is still under major construction)
•
•
Join Date: Jul 2008
Posts: 14
Reputation:
Solved Threads: 1
You should use
javascript Syntax (Toggle Plain Text)
document.bakeryImage.src=image
Xylude,
I'm amazed that
Try this - three goes in one line for good cross-browser compatibility plus the safety of setting null if they all fail:
Should work in all major browsers.
Airshow
I'm amazed that
bakeryImage.src=image; works in any browser! I can only think it's picking up on the name attribute rather than the id. Names are more liberally interpreted.Try this - three goes in one line for good cross-browser compatibility plus the safety of setting null if they all fail:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function swapImage(image){ var bakImg = (document.getElementById) ? document.getElementById('bakeryImage') : (document.images) ? document.images['bakeryImage'] : (document.all) ? document.all['bakeryImage'] : null; if(bakImg) bakImg.src = image; }
Airshow
50% of the solution lies in accurately describing the problem!
![]() |
Similar Threads
- Page looks different in Firefox for Mac than Firefox for Windows (HTML and CSS)
- Web Developer for IE and Firefox add ons (Web Development Job Offers)
- Layers and rollover issues (HTML and CSS)
- Rollover Issue in Firefox (ASP.NET)
- internet explorer rollover button troubles (HTML and CSS)
- Image Map Rollover error (JavaScript / DHTML / AJAX)
- mozilla firefox 0.8 (Windows NT / 2000 / XP)
- Problem viewing motion .gif and rollover... (Windows NT / 2000 / XP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: numeric class doesn't work
- Next Thread: Showing local time and timezone
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxcode ajaxhelp animate api automatically beta boarder box bug calendar card checkbox child class column cookies createrange() css cursor dependent disablefirebug dom download dropdown editor element engine error events explorer ext file firehose flash form forms game google gwt html htmlform ie8 iframe image() images internet java javascript jawascriptruntimeerror jquery jsf jsfile jump math matrixcaptcha microsoft mimic mp3 mysql object offline onmouseoutdivproblem onreadystatechange parent passing pdf php player post problem progressbar rated rating regex runtime scroll search select session shopping size sql star stars stretch text textarea twitter validation w3c web website window windowofwords windowsxp wysiwyg xml xspf \n





