SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    canada
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Style Sheet Switcher (v1.1) based on QueryString Parameter

    I am using the stylesheet switcher on dynamic drive . Is there a way to change stylesheets based on a querystring parameter? Basically, if the query string includes "&StyleSheet=BlueStyle" then call and set the BlueStyle.css and cookie on page load.

    Any ideas or help would be much appreciated. Thanks!!

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Absolutely, you could use a function like the below:

    Code JavaScript:
    function getUrlParam(name){
      var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
     
      if (!results) { return 0; }
      return results[1] || 0;
     
    }
     
    var newStyle = getUrlParam("stylesheet");
    chooseStyle(newStyle, 60)

    (This is a slight adaptation of a snippet I have in snipplr somewhere)
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  3. #3
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    canada
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do I implement this in the current JS? Sorry I am new at this. Thanks for any feedback.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •