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 October 19th, 2010, 09:26 AM
Authorized User
 
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
Default background colour of page

Hi there

I've never been asked this before so hence the posting but I've got a combination of asp vbscript and javascript working to perform a check on a value - if that value exceeds x amount then the prompt appears informing the user that they have added too much.

This is essentially it:

<%

if desiredValue >= 100 then

%>

<script language="javascript">
window.alert("Your total value must not exceed 100.00");
history.back();
</script>

<%


end if

%>

During the time the javascript alert appears the page background turns white - is there a way to make the background colour of the page different during the time the alert is on the screen?

thanks

Adam
 
Old October 23rd, 2010, 06:45 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Does it turn white? Or is it white all the time?

Your code seems to fire as soon as that part of the HTML is loaded which means the browser may not have enough HTML loaded to display the correct page. You could defer executing that JavaScript until the DOM has finished loading, using jQuery for example.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old October 25th, 2010, 11:37 AM
Authorized User
 
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
Default javascript: background colour

Hi Imar

It turns white, yes, but I think it's down to the DOM not loading the html since it's fired before then.

thanks

Adam
 
Old October 25th, 2010, 01:03 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
but I think it's down to the DOM not loading the html since it's fired before then
Yes, so you can emit some simpe HTML with the required background settings and then run your code when the DOM is ready.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Table row background colour changing meetravig Java GUI 0 September 21st, 2007 05:06 AM
Changing Fore colour and back colour darrenb Access VBA 2 May 25th, 2007 07:10 AM
Background colour/image printing ghari HTML Code Clinic 0 September 21st, 2006 01:05 PM
How to custom-define the default background colour ms_priya Java GUI 1 January 10th, 2006 05:28 PM
Setting backGround Colour of a text pazzuzu C++ Programming 0 January 21st, 2005 11:15 AM





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