SunQuest
 
           JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old July 25th, 2005, 09:08 AM
tkaram tkaram is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 2 tkaram User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 18 sec
Reputation Power: 0
Exclamation call javascript file from an image

Hi, i have a *.js file containing all the fuctions i need that build a menu.
In my page i have an image which i want to add on to it an on MouseEvent let's say onClick and when this image is clicked to bring the javascript file!

is this done??
i knwow it is done when i have a single Javascript function but what happens when i have a javscript file full of functions??


thank u!!

Reply With Quote
  #2  
Old July 25th, 2005, 09:22 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
You can't combine the image and javascript files themselves...

However you can include the *.js file in the HEAD of your page and call a method in the JS file from the onclick attribute of the IMG tag.

Code:
<html>
<head>
     <script type="text/javascript" src="whatever.js"></script>
</head>

<body>
     <img src="whatever.jpg" onclick="javascript:someMethod();">
</body>
</html>

Reply With Quote
  #3  
Old July 25th, 2005, 03:15 PM
tkaram tkaram is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 2 tkaram User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 18 sec
Reputation Power: 0
where will the method be declared??

thank u for your help, its understandable but where am i suppose to declare the method??
is it on the head section and including inside it the javascript link??

please can u make that more clear??

thank u

Reply With Quote
  #4  
Old July 26th, 2005, 09:56 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
In reference to my brief code example above, you could put your entire method in the whatever.js file.

You don't need to use a js file at all, you could embed all of your javascript code in the HEAD (within SCRIPT tags) if you want to, but it might be better as a seperate file.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > call javascript file from an image


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway