Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-09-2007, 07:16 PM   PM User | #1
Akuma
New to the CF scene

 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Akuma is an unknown quantity at this point
External js File For a Background

Firstly, sorry if my title description is vague but it was the best I could describe my little problem.

I am creating a new web site and the background for all the pages is going to be the same. I don't want to have to add the background for each page using background properties html code.

On my last web site I had used a js file which I placed on my server together with a little code on each page which called that js file, similar to the code below:

Code:
<script language="javascript" src="background.js"></script>
The problem is I had gotten rid of the js code and file on the last site and I don't remember what the coding I used was (in particular the coding in the background.js file). If anyone could help me out it would be greatly appreciated.
Akuma is offline   Reply With Quote
Old 01-09-2007, 07:22 PM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,532
Thanks: 0
Thanked 503 Times in 494 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
The background should be defined in an external stylesheet. There is no need for Javascript to do this as it is appearance and not behaviour that you are trying to define and appearance is defined by the stylesheet (placing it in the HTML is deprecated and is no longer the way to do it).
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 01-09-2007, 08:19 PM   PM User | #3
Akuma
New to the CF scene

 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Akuma is an unknown quantity at this point
Quote:
Originally Posted by felgall View Post
The background should be defined in an external stylesheet. There is no need for Javascript to do this as it is appearance and not behaviour that you are trying to define and appearance is defined by the stylesheet (placing it in the HTML is deprecated and is no longer the way to do it).
How do I go about creating an external stylesheet? I have no experience in using stylesheets but if there's any basics about on the subject I don't mind reading up on it.
Akuma is offline   Reply With Quote
Old 01-09-2007, 08:22 PM   PM User | #4
SpirtOfGrandeur
Regular Coder

 
Join Date: May 2005
Location: Michigan, USA
Posts: 566
Thanks: 0
Thanked 0 Times in 0 Posts
SpirtOfGrandeur is an unknown quantity at this point
Here appear to be a few examples...
__________________
Note: I do not test code. I just write it off the top of my head. There might be bugs in it! But if any thing I gave you the overall theory of what you need to accomplish. Also there are plenty of other ways to accomplish this same thing. I just gave one example of it. Other ways might be faster and more efficient.
SpirtOfGrandeur is offline   Reply With Quote
Old 01-10-2007, 12:58 AM   PM User | #5
Pyth007
Regular Coder

 
Join Date: Sep 2005
Posts: 535
Thanks: 0
Thanked 0 Times in 0 Posts
Pyth007 is an unknown quantity at this point
Also, here is W3Schools' tutorial on CSS... I noticed that the second example (in the CSS Examples section) goes into how to set a background image!
__________________
If you want answers, write a smart question.

Yes, someone probably does know how...

Oh, and if you want to learn, STFW!
Pyth007 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:00 AM.


Advertisement
Log in to turn off these ads.