Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 29th, 2004, 11:35 AM
Friend of Wrox
 
Join Date: May 2004
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.
 
Old July 29th, 2004, 11:56 AM
Friend of Wrox
 
Join Date: Jul 2003
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


 
Old July 29th, 2004, 12:18 PM
Friend of Wrox
 
Join Date: May 2004
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

 
Old July 29th, 2004, 12:20 PM
Friend of Wrox
 
Join Date: May 2004
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






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





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