Current location: Hot Scripts Forums » General Web Coding » JavaScript » onmouseover from external js

onmouseover from external js

Reply
  #1 (permalink)  
Old 10-18-09, 07:44 AM
knolly knolly is offline
Newbie Coder
 
Join Date: Apr 2009
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
onmouseover from external js

This has got to be so simple but I can't see what I'm doing wrong. Basically if I do this :

Code:
<img src="image.jpg" alt="" onmouseover="rollOverText('bio')"  />
then my rollOverText function works fine. But if I try to put the onmouseover in an external .<acronym title="JavaScript">js</acronym> file it doesn't work. Here's how I'm trying to do it:

Code:
<img src="image.jpg" alt="" id="biog"  />
and the script in the .<acronym title="JavaScript">js</acronym> file:


Code:
function menuRollovers() {
		document.getElementById('biog').onmouseover= rollOverText('bio');
}
	window.onLoad= menuRollovers();

Is this really obvious?

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-18-09, 09:27 AM
wirehopper's Avatar
wirehopper wirehopper is online now
Community Liaison
 
Join Date: Feb 2006
Posts: 1,562
Thanks: 2
Thanked 25 Times in 25 Posts
You might need quotes around it on the assignment.

"rollOverText('bio')";
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 10-18-09, 12:51 PM
knolly knolly is offline
Newbie Coder
 
Join Date: Apr 2009
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
hmmm, sadly no luck with that.

Thanks for the suggestion though!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 10-18-09, 12:54 PM
wirehopper's Avatar
wirehopper wirehopper is online now
Community Liaison
 
Join Date: Feb 2006
Posts: 1,562
Thanks: 2
Thanked 25 Times in 25 Posts
Is the window.onload in the main page or in the javascript file?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 10-18-09, 01:11 PM
knolly knolly is offline
Newbie Coder
 
Join Date: Apr 2009
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
in the javascript file
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 10-18-09, 01:26 PM
wirehopper's Avatar
wirehopper wirehopper is online now
Community Liaison
 
Join Date: Feb 2006
Posts: 1,562
Thanks: 2
Thanked 25 Times in 25 Posts
document.getElementById('dBlock1').setAttribute("o nmouseover","alert('test');return true;");

Tested under FF with FireBug.

There should not be a space between o and n.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 10-18-09, 01:34 PM
knolly knolly is offline
Newbie Coder
 
Join Date: Apr 2009
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
sorry, where do i put that? is that instead of window.onLoad? also is window.onLoad a good way of doing it?

thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 10-18-09, 05:47 PM
wirehopper's Avatar
wirehopper wirehopper is online now
Community Liaison
 
Join Date: Feb 2006
Posts: 1,562
Thanks: 2
Thanked 25 Times in 25 Posts
Same place

Code:
document.getElementById('biog').setAttribute("rollOverText('bio')");
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
The Following User Says Thank You to wirehopper For This Useful Post:
knolly (10-19-09)
  #9 (permalink)  
Old 10-19-09, 05:22 PM
knolly knolly is offline
Newbie Coder
 
Join Date: Apr 2009
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
hmmm, doesn't seem to help. Thanks anyway though!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 10-19-09, 05:39 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 7,536
Thanks: 5
Thanked 20 Times in 18 Posts
Try:
Code:
window.onload = function()
{
    document.getElementById('biog').onmouseover = function()
    {
        rollOverText('bio');
    }
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
The Following User Says Thank You to Nico For This Useful Post:
knolly (10-19-09)
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Textfield, CSS stylesheet external loading Flash_Boi Flash & ActionScript 1 03-03-09 07:43 AM
php wont work in external js file??? darksniperx PHP 3 10-20-07 11:43 PM
netBAQ™ External Storage Service - (Virtual Backup Storage) BurstNET General Advertisements 1 09-12-05 09:35 AM
SSO solution / JS for multiple logins needed... doedelkrake Script Requests 0 08-17-05 11:59 AM
refreshing external js file fs22 JavaScript 2 06-18-04 12:23 AM


All times are GMT -5. The time now is 12:05 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.