| | |
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 |
acid2 ajax ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box browser captchaformproblem cart child close codes column css date debugger decimal dependent design disablefirebug dom download element embed engine enter error events ext file firefox focus form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp jump libcurl listbox maps masterpage math media menu microsoft mimic mp4 onmouseoutdivproblem onmouseover onreadystatechange paypal pdf php player position post problem programming prototype redirect safari scale scriptlets scroll search security select software sql toggle unicode variables w3c web website window windowofwords \n





