RSS Forums RSS
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2680 | Replies: 4
Reply
Join Date: Apr 2006
Location: Australia
Posts: 10
Reputation: jiruiz78 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
jiruiz78 jiruiz78 is offline Offline
Newbie Poster

Question Random CSS

  #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!!:-|
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Posts: 1,592
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 35
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Random CSS

  #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  
Join Date: Feb 2006
Posts: 49
Reputation: Esopo is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 1
Esopo Esopo is offline Offline
Light Poster

Re: Random CSS

  #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  
Join Date: Apr 2006
Location: Australia
Posts: 21
Reputation: Tribolis is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Tribolis Tribolis is offline Offline
Newbie Poster

Re: Random CSS

  #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  
Join Date: Apr 2006
Location: Australia
Posts: 10
Reputation: jiruiz78 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
jiruiz78 jiruiz78 is offline Offline
Newbie Poster

Re: Random CSS

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:42 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC