473,396 Members | 2,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Inherit Background from previous page

Is it posssible to inherit the previous pages (parent pages)
background image? Is there a script out there I could look at? Thanks
Jul 20 '05 #1
4 5294
Grant Wagner <gw*****@agricoreunited.com> wrote in message news:<3F***************@agricoreunited.com>...
erik wrote:
Is it posssible to inherit the previous pages (parent pages)
background image? Is there a script out there I could look at? Thanks


The browser has no way of knowing what the background image of the
previous page was. If you want to use the same background image, you'll
have to set a cookie with the background image name and read it on each
page, or pass the image name around on the URL.


Not entirly true. I've got what the OP dscribes to work without
cookies or passing in the url.
I've only tested it in mozilla 1.4 and I wouldn't like to comment on
the 'goodness' of the method though :)

I found part of the answer here -

http://www.codebelly.com/javascript/...agechange.html

If you use the [depricated] background attribute of the body tag to
specify the image you can change/reference it with javascript. (I
can't get it to work with body background images defined with css
though.)

In the opened window call the following line of javascript with an
onload on the body tag

document.body.background=opener.document.body.back ground

mike.
Jul 20 '05 #2
Not sure I see the point of doing this.

Why not just set up the background-image property in a stylesheet like...

body { background-image:URL("bg1.gif"); }
body.specific { background-image:URL("bg2.gif"); }

Then refer to that from your web pages

<body class="specific"> which will pick up the bg2.gif background.
<body> will pick up the bg1.gif background.

I can see no conceivable purpose for inheriting the background from the
previous page, just use CSS.

Peter.

"mike" <in********************@hotmail.com> wrote in message
news:80**************************@posting.google.c om...
Grant Wagner <gw*****@agricoreunited.com> wrote in message

news:<3F***************@agricoreunited.com>...
erik wrote:
Is it posssible to inherit the previous pages (parent pages)
background image? Is there a script out there I could look at? Thanks


The browser has no way of knowing what the background image of the
previous page was. If you want to use the same background image, you'll
have to set a cookie with the background image name and read it on each
page, or pass the image name around on the URL.


Not entirly true. I've got what the OP dscribes to work without
cookies or passing in the url.
I've only tested it in mozilla 1.4 and I wouldn't like to comment on
the 'goodness' of the method though :)

I found part of the answer here -

http://www.codebelly.com/javascript/...agechange.html

If you use the [depricated] background attribute of the body tag to
specify the image you can change/reference it with javascript. (I
can't get it to work with body background images defined with css
though.)

In the opened window call the following line of javascript with an
onload on the body tag

document.body.background=opener.document.body.back ground

mike.

Jul 20 '05 #3
mike wrote:
Grant Wagner <gw*****@agricoreunited.com> wrote in message news:<3F***************@agricoreunited.com>...
erik wrote:
Is it posssible to inherit the previous pages (parent pages)
background image? Is there a script out there I could look at? Thanks


The browser has no way of knowing what the background image of the
previous page was. If you want to use the same background image, you'll
have to set a cookie with the background image name and read it on each
page, or pass the image name around on the URL.


Not entirly true. I've got what the OP dscribes to work without
cookies or passing in the url.
I've only tested it in mozilla 1.4 and I wouldn't like to comment on
the 'goodness' of the method though :)

I found part of the answer here -

http://www.codebelly.com/javascript/...agechange.html

If you use the [depricated] background attribute of the body tag to
specify the image you can change/reference it with javascript. (I
can't get it to work with body background images defined with css
though.)

In the opened window call the following line of javascript with an
onload on the body tag

document.body.background=opener.document.body.back ground

mike.


What you have done is open a new window and accessed the opener's background attribute. This is "inheriting"
the background image from a previous page. If that is what what the OP meant by "parent" page then sure, he
could jury rig the setup like this:

In Internet Explorer use:

<style type="text/css">
body { background-image:URL("3dblocks.gif"); }
</style>
<body>
<script type="text/javascript">
var w = window.open('about:blank');
w.document.body.style.backgroundImage = document.body.currentStyle.backgroundImage;
</script>

And in Mozilla you would use:

w.document.body.style.backgroundImage = document.defaultView.getComputedStyle(document.bod y,
"").backgroundImage;

Note that on a web site, both pages would have to come from the same domain for this to work, you can't
specify the backgroundImage for a page loaded in a new window which isn't from your domain.

Of course, the standard way to handle this is define the background image in one place, then specify:

<link rel="stylesheet" type="text/css" href="/path/to/file.css" />

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
* http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
* http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #4
Thats exactly what I ment - thanks Ill have to give this a whirl

Erik
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Kai Grossjohann | last post by:
Is there a way in CSS to say that I want to have a class apptoolbar which is just like the toolbar class, only with a different bg color? My q&d approach was to copy the toolbar class definition...
4
by: Gary Hasler | last post by:
I have a full page of thumbnails linked to home plan pages. I'm adding a mouseover/mouseout effect to the table cells, plus a onclick event to permanently set the cell background to indicate the...
5
by: Jeff | last post by:
Greetings I am beginning a web app. I am using C# aspx forms for my web pages. Is it possible to create/use one aspx file as a base from which to derive other aspx files? I can not get this to...
1
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say...
0
by: djus | last post by:
Hello At the begining I'm sorry for my English :( I want my aspx page TestPage.aspx to inherit from MyClass2. MyClass2 inherits from MyMainClass which is subtype of Page: public class...
2
by: cosmo_canuck | last post by:
Hi all! I'm a web designer who's valiantly struggling, with occasional moments of triumph, to build my first fully CSS site. Hope that you can answer a couple of quick newbie questions. Page:...
21
by: tradmusic.com | last post by:
Hi, We have the following in our stylesheet, which acts as a page header: #homepageheader { left: 0px; top: 0px; right: 0px; height: 183px; background-image:...
18
by: LayneMitch | last post by:
Hello. After getting great advice on positioning, I've edited my code and it's looking more stable. Now I need a little assistance with background image placement. Please click on this...
2
by: GTalbot | last post by:
Hello fellow comp.infosystems.www.authoring.stylesheets colleagues, Imagine this situation: #grand-parent-abs-pos { height: 400px; position: absolute; width: 600px; }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.