Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Apr 2006
Posts: 10
Reputation: jiruiz78 is an unknown quantity at this point 
Solved Threads: 0
jiruiz78 jiruiz78 is offline Offline
Newbie Poster

Random CSS

 
0
  #1
Apr 21st, 2006
Hello there, I need my page to randomly select a CSS document. I don't want the user to select it, but instead to do it when the page loads.
This is the script I have so far:

<script language="javascript" type="text/javascript">
var ranNum= Math.floor(Math.random()*3+1);
document.write("<link rel='stylesheet' href='hd"+ranNum+".css' type='text/css'>");
</script>


This function does write the proper <style> tag, but it does not work. :evil: When I go to "view source", I don't see the line that suppously was written by the JS function.

PLEASE HELP!!:-|
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Random CSS

 
0
  #2
Apr 21st, 2006
The "document.write" statement is deprecated in most new doctypes.

However, with a loose (or no) doctype, this should work. Where is the script running? It needs to run in the <HEAD> section of your page.

Give us a link?
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 50
Reputation: Esopo is an unknown quantity at this point 
Solved Threads: 1
Esopo Esopo is offline Offline
Junior Poster in Training

Re: Random CSS

 
0
  #3
Apr 22nd, 2006
When I go to "view source", I don't see the line that suppously was written by the JS function.
You don't usually get to see the line that was written, since it happens on the client. The "view source" option gives you the original source, not the client-execution result.
Site admin at NetBulge.com, a place set out to improve the web 1 good article at a time :)
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 21
Reputation: Tribolis is an unknown quantity at this point 
Solved Threads: 0
Tribolis Tribolis is offline Offline
Newbie Poster

Re: Random CSS

 
0
  #4
Apr 22nd, 2006
I need my page to randomly select a CSS document. I don't want the user to select it, but instead to do it when the page loads.
Is that mean skin chooser? For user selects the CSS style and reload the page.
WeLoveCSS.com XHTML/CSS Forum for beginners to advanced users
Can't find any good CSS Forums? WLC is the right place for you!
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 10
Reputation: jiruiz78 is an unknown quantity at this point 
Solved Threads: 0
jiruiz78 jiruiz78 is offline Offline
Newbie Poster

Re: Random CSS

 
0
  #5
Apr 23rd, 2006
Me again, sorry for the late response, it was the weekend.
I don't want the user to select the a CSS and then refresh the page. I want to do that for them.

The way I have setup my page is that I have one CSS for the whole page: styles.CSS, and then I have 3 other CSS documents (hd1.css, hd2.css, hd3.css) that I want to use them in the document randomly.

Here is the page
http://www.arch.usyd.edu.au/~jrui0688/template.htm

(this is the testing page).
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC