Solved

OnMouseOver event

Posted on 1998-06-21
7
439 Views
Last Modified: 2011-09-20
Please could someone tell me why this generates an error?
It seems to work (nearly!)

<font onMouseOver="this.style.font='bold' " onMouseOut="this.style.font='normal'">
<p>Text to change </font></p>

Ta.
0
Comment
Question by:phooey
7 Comments
 

Expert Comment

by:dima_sherman
ID: 1844315
Hi, goto http://hey.to/hillz and read the source of the page.
0
 
LVL 2

Author Comment

by:phooey
ID: 1844316
This does not really answer my question.  I am already familiar with changing colour, text etc onMouseOver but I want to make the text bold?
0
 
LVL 8

Expert Comment

by:MaDdUCK
ID: 1844317
did you include a "... return true" statement in the JavaScript line?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Expert Comment

by:martinag
ID: 1844318
I think it is impossible to do what you want to do.
The font colors are changeable because they are set with <FONT></FONT>
But bold is a special tag (<B></B>) and normal hasn't got any tag at all.
0
 

Expert Comment

by:Spo0n
ID: 1844319
This doesn't solve it but it's as close as I could get..so it's not really an answer i spose...

<script language=JavaScript>

function goBold(textIn) {
textaOn = textIn.bold();
document.write(textaOn);
}

function goNormal(textIn) {
textaOff = textIn;
document.write(textaOff);
}

</script>
<body>
<font onMouseover="goBold('hurro'); return true;" onMouseout="goNormal('indeed'); return true;">indeedily</font>
</body>

It works....but wont change back with onMouseout...it seems to kill the page and wont reload...you have to reopen the file.
I tried heaps of things like using ' this ' as input with different results.....none of which worked.  It's really just an image flipping function but the text is making it go a little err 'wobbly'.  :)   Good luck.
0
 
LVL 2

Author Comment

by:phooey
ID: 1844320
Sorry guys, worked it out myself.  For interest:
Set up two styles, one for onMouseOver and one for onMouseOut.  In the style you can set the font colour and weight and anything else you care to mention.

(Free 10 points to anyone who answers this, just to get it off the list)
Dave.
0
 
LVL 8

Accepted Solution

by:
MaDdUCK earned 50 total points
ID: 1844321
DId you set these style up with a style sheet? You could do the font weight thingy right in the tag because unlike bold, font weight is controlled via the font tag (or more like through the style tag)

Do you want this for links or for normal text. If you do it for links, then I guess it is best to define the styles a.link and a.hover because then this will happen automatically.

Good luck!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now