Setting web page background color

I can set the background color of the current page using: document.body.style.background=’red’;Is there any way I can set the color of a page from another page?Note: I can set the color when a page contains frames. In this case, consider the scenario similar to two different tabs of a browser.……………

via HTML Language Development » Search Results » ajax:

Setting web page background color

I can set the background color of the current page using:
document.body.style.background=’red’;Is there any way I can set the color of a page from another page?
Note: I can set the color when a page contains frames. In this case, consider the scenario similar to two different tabs of a browser.
…………………………..

Yes, providing:
You have a reference to the other page (such as the return value of window.open)
The page is on the same origin
Then just use said reference.
…………………………..

John K’s comment is a good solution. If you’re loading the other page synchronously (ie full page load, not AJAX) then obviously you’re going to have to maintain the state between pages. The very nature of HTTP is pretty stateless, so a query-string is a nice simple solution for persisting data such as a background colour.
…………………………..

If you are trying to set apge background color using javascript, you can document.body.style.backgroundColor in your js code.
And if you want to set the bgcolor of a page from another page you need to use query string and pass the color in a variable to the other page and set the other page background color using that variable value on page load or whatever way you want.
…………………………..

seems only if you have opener.

For more info: Setting web page background color

HTML Language Development » Search Results » ajax

Setting web page background color

Share this post:

Related Posts

Leave a Comment