Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8739613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:58:18+00:00 2026-06-13T10:58:18+00:00

function readCookie(name) { var ca = document.cookie.split(‘;’); var nameEQ = name + =; for(var

  • 0
function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
  return null;
}

document.ready(function() {

var color = readCookie(go);

if (color != null) {

var gs = document.createElement("link");
gs.type = "text/css";
gs.rel = "stylesheet";
gs.title = "mystyle"
gs.href = "images/audentio/gogreen/green.css";

var rs = document.createElement("link");
rs.type = "text/css";
rs.rel = "stylesheet";
rs.title = "mystyle"
rs.href = "images/audentio/gogreen/red.css";

var bs = document.createElement("link");
bs.type = "text/css";
bs.rel = "stylesheet";
bs.title = "mystyle"
bs.href = "images/audentio/gogreen/blue.css";

if (color == "green"){
    document.getElementsByTagName("head")[0].removeChild(rs);
    document.getElementsByTagName("head")[0].removeChild(bs);
    document.getElementsByTagName("head")[0].appendChild(gs);
}

else if (color == "blue"){
    document.getElementsByTagName("head")[0].removeChild(rs);
    document.getElementsByTagName("head")[0].removeChild(gs);
    document.getElementsByTagName("head")[0].appendChild(bs);
}

else (color == "red"){
    document.getElementsByTagName("head")[0].removeChild(gs);
    document.getElementsByTagName("head")[0].removeChild(bs);
    document.getElementsByTagName("head")[0].appendChild(rs);
}
}
else {
return: false;
}
});

Hey guys, I’m no good with this stuff, it’s killing all the jQuery in my page (Though for reasons I won’t go into, I don’t want to use jQuery for the reading of the cookie, only the creating of it) so any chance someone can see the error?

Live Demo: http://wedesignthe.net/staff_uploads/eric/ad_development/demo/index.php

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:58:19+00:00Added an answer on June 13, 2026 at 10:58 am

    Find else (color == "red"){ and replace with else if(color == "red"){

    The error due to this statement else (color == "red"){ where you just forgot if

    and change

    else {
        return: false;
    }
    

    to

    else {
        return false;
    }
    

    remove : between return and false

    and change document.ready(function() { to $(document).ready(function() { or $(function() {

    Replace it

    if (color == "green"){
        document.getElementsByTagName("head")[0].removeChild(rs);
        document.getElementsByTagName("head")[0].removeChild(bs);
        document.getElementsByTagName("head")[0].appendChild(gs);
    }
    
    else if (color == "blue"){
        document.getElementsByTagName("head")[0].removeChild(rs);
        document.getElementsByTagName("head")[0].removeChild(gs);
        document.getElementsByTagName("head")[0].appendChild(bs);
    }
    
    else if (color == "red"){
        document.getElementsByTagName("head")[0].removeChild(gs);
        document.getElementsByTagName("head")[0].removeChild(bs);
        document.getElementsByTagName("head")[0].appendChild(rs);
    }
    

    with

    var head = document.getElementsByTagName("head")[0];
    var links = head.getElementsByTagName("link");
    for(var x=0; x<links.length ; x++)
    {
       var href = links[x].href;
        if(href.indexOf('/green.css') >0 || href.indexOf('/red.css') >0|| href.indexOf('/blue.css') >0){
          head.removeChild(links[x]);
       }
    }
    
    if (color == "green"){
        head.appendChild(gs);
    }
    else if (color == "blue"){
        head.appendChild(bs);
    }
    
    else if (color == "red"){
       head.appendChild(rs);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: <script language=javascript type=text/javascript> function readCookie(name) { var nameEQ =
function getWindowsUserName() { var WinNetwork = new ActiveXObject(WScript.Network); var urlToSite = createCustomURL(WinNetwork.UserName); document.getElementById(psyncLink).src =
I know how to write/create cookies in JavaScript......................................................... //Create the cookies document.cookie = Name=
<input id=Edit name=Edit value=Edit Record type=button onclick=$.get('fetchvalues.php', function(){myCallBack(ReadCookie('UpdateRecordID'));}); /> The ReadCookie function is of
function countChars(elm) { if (elm.nodeType == 3) { // TEXT_NODE return elm.nodeValue.length; } var
function ExChgClsName(Obj,NameA,NameB){ var Obj=document.getElementById(Obj)?document.getElementById(Obj):Obj; Obj.className=Obj.className==NameA?NameB:NameA; } <a href=javascript:showMenu(2);> i am a newbie of the
function Apple(){ this.name=apple; } function Orange(){ this.name=orange; this.apple = new Apple(); this.apple.onCalled=function(){ alert(this.name); }
function checkuser(user) { var ret = false; $.ajax({ type:'POST', url:'user.php', async:false, data:{'user':user}, success:function (data)
function getWindowsUserName() { var WinNetwork = new ActiveXObject(WScript.Network); var urlToSite = http://localhost/index.php?nph-psf=0&HOSTID=AD&ALIAS= + WinNetwork.UserName;
function Person() {} Person.prototype.population = 0; Person.prototype.constructor = function(name) { this.name = name; console.log(Name:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.