I\'m trying to create a dynamic page using external .css pages where the page color will get changed. Below is my code. But when I click the href
, I am not gett
Tim Goodman's answer is correct, but instead of fileref.href = "filename";
it should be fileref.href = filename;
Otherwise you're trying to load a file with the name "filename" rather than what you passed to the script.
Alternately, if you're willing to use the jQuery library, this can be accomplished in one line:
$("head").append("");
Also, about the first version of your script using setAttribute: Most browsers will only take setAttribute with an empty third parameter because of the way the spec is set up:
fileref.setAttribute("href", filename, "");