PDA

View Full Version : Javascript for local custom CSS



thegooddale
04-09-2006, 06:00 AM
Hi, I'm trying to alter this Greasemonkey Javascript that a friend wrote for me. I would like for it to point to a CSS stylesheet that is located on my hard drive, rather than on my server. I have tried changing the address after @import to file:///C:/folder/folder/file.css without any success. Is it possible to somehow link to a stylesheet that is on my hard drive?

The code:

// ==UserScript==
// @name CSS-Test
// @include http://www.mycoffeelounge.net/*
// @include http://mycoffeelounge.net/*
// ==/UserScript==



function addStyle(style) {
var head = document.getElementsByTagName("HEAD")[0];
var ele = head.appendChild(window.document.createElement( 'style' ));
ele.innerHTML = style;
return ele;
}

addStyle('@import "http://www.forboden.com/mcl/123-latest.css";');

Twey
04-09-2006, 07:53 AM
I believe it should be

addStyle('@import url(file://C:/folder/folder/file.css);');Try that and see how it goes.