Nov 21, 2009
Pages: 1, 2

OnMouseOver Button

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > JavaScript

OnMouseOver Button

TavoxPeru
Hi, this little code is perfect for adding short instructions on a submit button, simply add your text to the mouseover event of the button, for example:

<input type="submit" value="Click here" onmouseover="this.value='== Just click once! =='" onmouseout="this.value='Click here!'">

regards,

Comment/Reply (w/o sign-up)

pyost
This is a very handy function, and there is another place where it is quite useful. In CSS, you can create buttons that change their background colour when the mouse pointer is above them. However, this can be achieved by using JavaScript and HTML.

CODE
<td width="60" onmouseover="this.bgColor='#9db5c8';" onmouseout="this.bgColor='#c0d3e7';">


The table cell will be #c0d3e7 until the mouse pointer comes to it. Then it will become #9db5c8.

Comment/Reply (w/o sign-up)

Ky1e
Very useful little snippet, Tavox. Can you use a code for when you put your mouse over a picture, a little box comes up next to the cursor with writing? If you know what I'm talking about, I need that code. Its a very useful little one as well
Thanks

-Kyle

Comment/Reply (w/o sign-up)

seec77
The code for the alternate text is something like this:
CODE

<img src="..." alt="Alternate text here!" />

You should give all your images (other than spacer/background ones) alternate texts, so that users with vision impairment or text-based browsers will be able to browse your site easily. Alt also helps when you have a broken image, i.e. an image not loading correctly for the user - the user will still be able to see what was supposed to be in the picture. It has nothing to do with Javascript or CSS! biggrin.gif

Comment/Reply (w/o sign-up)

TavoxPeru
QUOTE(Ky1e @ Aug 5 2006, 02:13 PM) *

Very useful little snippet, Tavox. Can you use a code for when you put your mouse over a picture, a little box comes up next to the cursor with writing? If you know what I'm talking about, I need that code. Its a very useful little one as well
Thanks

-Kyle

one way is by using the alt attribute as seec77 said, the other way is by using the title attribute, and the syntax is similar as the alt attribute:
CODE
<img src="your_image_file" alt="your alternate text goes here" title="your title text goes here" ...>

Now, i recommend that you use both attributes with the same text because with firefox only works one of them, i'm not sure which one is, sorry but in this moment i dont remember. sad.gif

Best regards,

 

 

 


Comment/Reply (w/o sign-up)

pyost
The "title" attribute is the one you should use. A long time ago (biggrin.gif) "alt" was the only attribute, and it was supposed to be shown when the image can't be displayed. However, many people used it to give image a title. So as to solve this problem, the "title" tag was introduced. Now, since the problem was solved, "alt" is used to describe image in case it doesn't display, whereas "title" gives image a title which is displayed as a tooltip.

Comment/Reply (w/o sign-up)

eliments
Useful for sure.... please inform me of any other useful tips.... that makes things much simpler.
The code for something even that simple was not so fun to always have to write. :/
Thanks for the tip^^

Comment/Reply (w/o sign-up)

TavoxPeru
QUOTE(pyost @ Jul 30 2006, 06:23 AM) *
This is a very handy function, and there is another place where it is quite useful. In CSS, you can create buttons that change their background colour when the mouse pointer is above them. However, this can be achieved by using JavaScript and HTML.

CODE
<td width="60" onmouseover="this.bgColor='#9db5c8';" onmouseout="this.bgColor='#c0d3e7';">


The table cell will be #c0d3e7 until the mouse pointer comes to it. Then it will become #9db5c8.

That's correct, you can achieve that with JavaScript and HTML but only to say that this can also be achieved with the CSS's :hover pseudo-class that everyone use with the HTML's A tag, but do you know that you can also use this pseudo-class with other elements not only with the A tag???? honestly i don't, and i just discover it a few days ago.

I'm talking about the :hover, :active and :focus pseudo-classes, you can use these pseudo-classes with other HTML elements like forms, input boxes, legend, fieldsets, etc. to achieve awesome effects in your pages, and the nice thing is that when you validate your CSS you dont worry about it because are VALID, but as usual this doesn't work fine with IE.

So, please visit the following page Contact Us first using Firefox and then with IE to see what i'm talking about.

Best regards,

Comment/Reply (w/o sign-up)

pyost
QUOTE(TavoxPeru @ Mar 17 2007, 05:16 AM) *
but as usual this doesn't work fine with IE


Of course... Luckily, there are several ways of getting rid of this problem, or even avoiding it. First of all, you should try to create the necessary effect with <a> only, since it is sure to work in all browsers. If this, however, isn't possible, you can try using the whatever:hover hack. It is a .htc file that enables hover functionality for all elements in Internet Explorer. Here is the link: http://www.xs4all.nl/~peterned/csshover.html

Personally, I don't like using any hacks. Instead, I tend to make my pages the same in all browsers by using pure, valid CSS, with no JavaScript at all. However, I do give the advantage to JavaScript, since it is not a hack, but a normal option. If someone does not have JavaScript enabled, it's his/her problem - that's like living in the past!

Comment/Reply (w/o sign-up)

sparkx
QUOTE(TavoxPeru @ Jul 30 2006, 04:55 AM) *
Hi, this little code is perfect for adding short instructions on a submit button, simply add your text to the mouseover event of the button, for example:
<input type="submit" value="Click here" onmouseover="this.value='== Just click once! =='" onmouseout="this.value='Click here!'">

I use this function a lot mainly for roll-over effects as it is easyer then uploading a .swf (Macromedia flash 8 file). You could use it for text but its cooler if its images. There are examples everywhere. Ever been to a website with buttons that glow when your mouse is over them? That what it is. I think everyone should lean this command because it can be added on-to to make some pretty cool effects.
Thanks,
Sparkx

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Pages: 1, 2

See Also,

*SIMILAR VIDEOS*
Searching Video's for onmouseover, button
advertisement



OnMouseOver Button

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com