calling a function

They have: 37 posts

Joined: Oct 1999

I am currently trying to call a function that will insert a style in my document but when it is called it reloads the document and makes it blank. Is there a way to keep the current text there. I read something about document.open but I am not quite sure how to use it. Here is my current code.

function style1() {
document.write('<link type="text/css" href="style1.css" REL="STYLESHEET">');
}

<a href="javascript:style1()">SOME</a>

Jack Michaelson's picture

He has: 1,733 posts

Joined: Dec 1999

What you're trying to do is not possible.
The section of a HTML-page.
A document.write cannot write something in the -section so your function is not usable.

I must say that I'm curious: Why do you wanna have this kinda function??

Jack Sticking out tongue

Shakespeare: onclick || !(onclick)

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.