Welcome visitor
* Login
* Register
It is currently January 24th, 2019, 10:38 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » HTML



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  Using events in html
PostPosted: October 3rd, 2009, 7:35 pm 

Posts: 33
I have an image that i want to use dinamically, e.g. react when the mouse is over it or out of it. I added the onmouseover() and onmouseout() but i dont know what to do next. Can you point me in the right direction of using this "events" (as i found they are called)?


Top
 Profile  
 
  Re: Using events on html
PostPosted: October 4th, 2009, 3:57 am 
User avatar

Posts: 112
that is not html but javascript language. Yes, onmouseover & onmouseout are events and to assign actions to it you should add them to the event:
<img src="image.jpg" onmouseover="alert('this is an example');" />

this is another way to do the same thing
<script type="text/javascript">
function insideImg(){alert('this is an example');}
</script>
<img src="image.jpg" onmouseover="function insideImg();" />

usually the parentheses are used to send variables values.

and a third way to do this would be using a .js file which you can create using any text editor but save it with a .js extension. the content for that file should be
function insideImg(){alert('this is an example');}

and on your html file add this tag
<script src="yourFileName.js"></script>

and then just call the function from the image
<img src="image.jpg" onmouseover="function insideImg();" />
as with any other language a function can be used by any other element that is realted to it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » HTML


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron