Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 29th, 2004, 11:35 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default Button Font Attribute

Hey all,

Im having some difficulty here. I have a button which takes you home. However, onmouseover fires a script which uses onTimeout() to change it from one color to another and then back again. Im also trying to make the font weight change in time. Im just fussy I guess but heres my code lol:

<form name ="Form1">
<input type = "button" name ="homebut" onclick ="homefunction()" onmouseover ="flasher()" onmouseout ="normalit()"></form>
<script language ="javascript">
function flasher(){
var mytimer;
mytimer = window.setTimeout("changeup()", 200)
}
function changeup(){
document.Form1.homebut.style.backgroundColor ='blue';
document.Form1.homebut.style.font ='bold';//this is causing major errors.
mytimer = window.setTimeout("changedown()", 200)
}
function changedown(){
document.Form1.homebut.style.backgroundColor ='white';
mytimer = window.setTimeout("changeup()", 200)
}
</script>
<script language ="javascript">
function normalit(){
window.clearTimeout(mytimer);
document.Form1.homebut.style.backgroundColor ='';
}
</script>

Help would be much appreciated.

Thanks
interrupt

__________________
\'sync\' &lt;cr&gt;
The name specified is not recognized as an internal or external command, operable program or batch file.
Reply With Quote
  #2 (permalink)  
Old July 29th, 2004, 11:56 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi interrupt,

tweaked your code a tiny bit & it works - made mytimer a global and changed document.Form1.homebut.style.font to document.Form1.homebut.style.fontWeight...

Code:
<form name ="Form1">
<input type = "button" value="Some Text" name ="homebut" onclick ="homefunction()" onmouseover ="flasher()" onmouseout ="normalit()"></form>
<script language ="javascript">
var mytimer;

function flasher(){

    mytimer = window.setTimeout("changeup()", 200)
}
function changeup(){
    document.Form1.homebut.style.backgroundColor ='blue';
    //document.Form1.homebut.style.font ='bold';//this is causing major errors.
    document.Form1.homebut.style.fontWeight = 'bold';
    mytimer = window.setTimeout("changedown()", 200)
}
function changedown(){
    document.Form1.homebut.style.backgroundColor ='white';
    mytimer = window.setTimeout("changeup()", 200)
}
</script>
<script language ="javascript">
function normalit(){
    window.clearTimeout(mytimer);
    document.Form1.homebut.style.backgroundColor ='';
    document.Form1.homebut.style.fontWeight = 'normal'
}
</script>
Best regards,

Chris


Reply With Quote
  #3 (permalink)  
Old July 29th, 2004, 12:18 PM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oh my God. lol. Can't believe it's just a matter of syntax, but would have been rippin my hair out. Thanks Chris.

interrupt

Reply With Quote
  #4 (permalink)  
Old July 29th, 2004, 12:20 PM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

One thing I've noticed with onmouseout is that you can get your mouse out before the onmouseout event has time to fire! Any way round this?

interrupt

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace an attribute with another attribute georgemeng XSLT 8 June 10th, 2008 11:04 AM
How do I get the value attribute of a radio button muymoy_2001 General .NET 3 October 29th, 2007 03:09 AM
how to get font ,color,font size of text in win32 satishsatao Visual C++ 0 April 5th, 2006 05:05 AM
radio button font background color interrupt CSS Cascading Style Sheets 1 November 18th, 2005 09:21 AM
Access to attribute values from class of attribute jacob C# 1 October 28th, 2005 01:11 PM



All times are GMT -4. The time now is 01:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.