473,769 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Body Color change

4 New Member
Hi Everybody,

m suyoz,

i have made body color change onmouse click in every webpages but what i want is dat when i choose for eg blue body color .after dat when i click on link to other page i want same color which i have chosen before[blue] .. so please help me..
Feb 7 '08 #1
9 3017
shoeyoz
4 New Member
i have made body color change onmouse click ..but i want is to make default color or if one goes to other page dat page must open with same body color dat i have chosen..can anyone help me..please

script for color change

Expand|Select|Wrap|Line Numbers
  1. var backImage = new Array(); 
  2.  
  3. backImage[0] = "images/bg.jpg";
  4. backImage[1] = "images/background.jpg";
  5. backImage[2] = "images/dark.jpg";
  6. backImage[3] = "images/white";
  7. backImage[4] = "images/lightblue.jpg";
  8. backImage[5] = "images/lightpink.jpg";
  9. backImage[6] = "images/grey.jpg";
  10. backImage[7] = "images/1.jpg";
  11. backImage[8] = "images/2.jpg";
  12. backImage[9] = "images/eeeeee.jpg";
  13. backImage[10] = "images/3.jpg";
  14. backImage[11] = "images/4.jpg";
  15. backImage[12] = "images/5.jpg";
  16. backImage[13] = "images/6.jpg";
  17. backImage[14] = "images/7.jpg";
  18. backImage[15] = "images/8.jpg";
  19. backImage[16] = "images/9.jpg";
  20. backImage[17] = "images/10.jpg";
  21. backImage[18] = "images/11.jpg";
  22. backImage[19] = "images/12.jpg";
  23. backImage[20] = "images/13.jpg";
  24. backImage[21] = "images/14.jpg";
  25. backImage[22] = "images/15.jpg";
  26. backImage[23] = "images/16.jpg";
  27. backImage[24] = "images/17.jpg";
  28. backImage[25] = "images/18.jpg";
  29. backImage[26] = "";
  30.  
  31. function changeBGImage(whichImage){
  32. if (document.body){
  33. document.body.background = backImage[whichImage];
  34.  
  35. }
  36. }
Feb 8 '08 #2
dlite922
1,584 Recognized Expert Top Contributor
If your not using any server side language, like PHP or ASP, then you need to have two functions:

1 function will put the values in the URL like

somepage.html?b g=2

2nd function will retrive it that value.

Here's the function that retrives the value of a parameter and returns an empty string if it is not found:

http://www.netlobo.com/url_query_string_javascript.html

Second, you need to pass this value to each of your pages.

I would have a changePage() function and evey link in your page will need to use this function to change the page.

Expand|Select|Wrap|Line Numbers
  1.  
  2. // put this at the top of your script
  3. var bgNum = 0; // 0 or any other one you want as default. 
  4.  
  5.  
  6. function changePage(URL)
  7. {
  8.     window.location = URL + "&bgNum=" + bgNum;
  9. }
  10.  
  11.  
  12. // modify your changeBGImage function to
  13. function changeBGImage(whichImage)
  14. {
  15. if (document.body){
  16. document.body.background = backImage[whichImage];
  17.  
  18. bgNum = whichImage; // store it in bgNum Variable. 
  19.  
  20. }
  21.  
  22. // to load the bg on the next page you use that gup in the link i gave you
  23.  
  24. document.body.background = gup(bgNum);
  25.  
  26. // or call that with the body onload function like so: 
  27.  
  28. <body onLoad="document.body.background=gub(bgNum);">
  29.  
  30.  
  31.  
  32.  
Hope that helps you to be on your way... post any questions.
Feb 8 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
Merged thread on the same topic. Please keep all posts relating to one specific problem in one thread. Thanks!
Feb 8 '08 #4
shoeyoz
4 New Member
If your not using any server side language, like PHP or ASP, then you need to have two functions:

1 function will put the values in the URL like

somepage.html?b g=2

2nd function will retrive it that value.

Here's the function that retrives the value of a parameter and returns an empty string if it is not found:

http://www.netlobo.com/url_query_string_javascript.html

Second, you need to pass this value to each of your pages.

I would have a changePage() function and evey link in your page will need to use this function to change the page.

Expand|Select|Wrap|Line Numbers
  1.  
  2. // put this at the top of your script
  3. var bgNum = 0; // 0 or any other one you want as default. 
  4.  
  5.  
  6. function changePage(URL)
  7. {
  8.     window.location = URL + "&bgNum=" + bgNum;
  9. }
  10.  
  11.  
  12. // modify your changeBGImage function to
  13. function changeBGImage(whichImage)
  14. {
  15. if (document.body){
  16. document.body.background = backImage[whichImage];
  17.  
  18. bgNum = whichImage; // store it in bgNum Variable. 
  19.  
  20. }
  21.  
  22. // to load the bg on the next page you use that gup in the link i gave you
  23.  
  24. document.body.background = gup(bgNum);
  25.  
  26. // or call that with the body onload function like so: 
  27.  
  28. <body onLoad="document.body.background=gub(bgNum);">
  29.  
  30.  
  31.  
  32.  
Hope that helps you to be on your way... post any questions.


//Sorry it didn't work.. Well thanks for ur code once again thanks for showing some way now i can try it

bye

suyoz..
Feb 13 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
//Sorry it didn't work.. Well thanks for ur code once again thanks for showing some way now i can try it
What didn't work? Give more details.
Feb 14 '08 #6
shoeyoz
4 New Member
What didn't work? Give more details.
u can check in this url http://www.dobaltechno lgies.com
and i have paste the script above..
so please help me..

i want if bodycolor change once than when u'll visit other page bodycolor of visited page must not be changed it should be remain same .

thanks
Feb 14 '08 #7
acoder
16,027 Recognized Expert Moderator MVP
Use cookies. When you set the body colour, set a cookie. On the next page, retrieve the cookie and set the body colour based on that. If you don't know how to get/set cookies, see this tutorial.
Feb 14 '08 #8
Zorba CafeSpeak
1 New Member
Hi ... Could you tell me how to do the same thing but within a table in a html page... When I tried using document.body.b ackground, the effect comes up in the page background not the table background...

Thanks for your help

Zorba
Feb 21 '08 #9
acoder
16,027 Recognized Expert Moderator MVP
Hi ... Could you tell me how to do the same thing but within a table in a html page... When I tried using document.body.b ackground, the effect comes up in the page background not the table background...

Thanks for your help

Zorba
Set the table's style.backgroun dColor property.
Feb 21 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

9
3943
by: Timothy Madden | last post by:
Hy all In my application I'll receive XML text in the HTTP-message body in a particular format that only my application understands My script will be requested by the client with HTTP POST and the HTTP request will contain the XML as reqest-message body I couldn't find a way to acces the POST message body in my script to parse the XML and extract my data. I know I can get the request-message headers and I know I can set some of the...
9
3736
by: Frances Del Rio | last post by:
when I test my stuff with the validator in HomeSite it tells me the body tag no longer reads margin attributes.. does this mean now margins are to be specified only in CSS? I work for an internet co., they support IE 5+ and the old pre-6 Netscape.. if you don't put this tag in html docs, what version of HTML does it default to? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
5
2765
by: Ney André de Mello Zunino | last post by:
Hello. Running the following document through the W3C's validator, returns the error: "end tag for "body" which is not finished." <!-- Start of sample document --> <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
6
3483
by: mike | last post by:
I have created a side application in VB.NET which reads rows from a DB and builds an email message. when i have a long string the the mailmessage.body or the mailmessage, it puts in an "!<linefeed><space>" at about every 980th space. I have confirmed that these characters are not in the string or the message body before the email is sent. Has anyone seen this or have any thoughts? Thanks
7
3256
by: Tony Johansson | last post by:
Hello!! Assume I have a handle body pattern with classes called Handle and Body. In the Body class I store one int value for example 7 or some other integer value. In the Handle class I have a pointer to the Body class. If a want to create a STL container of List with the following declaration List <Handle <Body> > list
64
3404
by: Morgan Cheng | last post by:
Hi All, I was taught that argument valuse is not supposed to be changed in function body. Say, below code is not good. void foo1(int x) { x ++; printf("x+1 = %d\n", x); } It should be "refactor-ed" to be
6
2045
by: tshad | last post by:
Is there a way during Page_Load to change or add an attribute to the Body tag? I want to be able to change the onLoad body attribute to do a focus on one of my text boxes, such as: onLoad="document.forms.txtLogon.focus();" The problem is I have my <body> in an include file and want to set the onLoad attribute during Page_Load time.
1
4492
by: jessicahagg | last post by:
Hi, Goal: Change report body background color to white at runtime before exporting to pfd format. I am reproducing a web report useing .Net reportviewer -- The report is to have the same background color as the web page but a white/no background color when exported to a pdf. - Setting the report page body to transparent does not work. - Using a css on the reportviewer background does not work. How can I access the report's page...
6
2559
by: _Who | last post by:
I use the code below to change to a style sheet that has: body { ....
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.