Computing.Net > Forums > Web Development > Preferred Stylesheet Not Loading

Preferred Stylesheet Not Loading

Reply to Message Icon

Original Message
Name: Zyd
Date: September 1, 2005 at 21:12:56 Pacific
Subject: Preferred Stylesheet Not Loading
OS: WinXP Pro SP2
CPU/Ram: P3 533Mhz/256MB
Comment:

I've got a website that I work on for fun. I don't have any formal education in coding websites which will probably show if you visit the site. I'm just learning as I go but my current problem is that the preferred stylesheet isn't loading up when people initially visit the site. The styles only work after someone uses the 'choose a style' page which uses a piece of javascript to set a cookie.

How can I get the preferred style to load up first time around? Site address is: www.oncewas.com


Report Offensive Message For Removal

Response Number 1
Name: Michael J (by mjdamato)
Date: September 1, 2005 at 21:36:38 Pacific
Subject: Preferred Stylesheet Not Loading
Reply: (edit)

Without "really" reading through your code, it looks like you could do the following:

Change the red line in the javascript below to the bold line:

window.onload = function(e) {
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
var title = cookie ? cookie : 'default';
if ()
setActiveStyleSheet(title);
}


It also looks like you can get rid of the function getPreferredStyleSheet() unless it is used elsewhere. That function was the problem - it needs to return the value for the default style sheet and the value it returned didn't coresspond to any of the style sheets I saw



Report Offensive Follow Up For Removal

Response Number 2
Name: Zyd
Date: September 1, 2005 at 22:11:43 Pacific
Subject: Preferred Stylesheet Not Loading
Reply: (edit)

Michael J,

I found the styleswitcher script at 'A List Apart' written by Paul Sowden. I wasn't sure on what to change in it myself, but what you said above worked like a charm. Thanks for your help, I appreciate it.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Preferred Stylesheet Not Loading

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software