...

setting a property that has only a getter

ChuckRW
04-24-2003, 07:36 AM
Hi,
I need to use a seperate external css for EI5+ and NS6+ browsers. I am currently using the following code in the head of my page. It works fine but when the page loads in NS6 it gives the error: "setting a property that has only a getter" in the JavaScript debugger. How can I clear up this error?

Here's the code that I use:

<link rel="stylesheet" type="text/css" href="resources/sg7ns.css">
<script type="text/javascript">
<!--
if (document.styleSheets) document.styleSheets[0].href="resources/sg7ie.css"
// -->
</script>

Here's a link to see the page I use the script on. (the page/site is far from finished, mousing over certain links will cause errors that have nothing to do with my problem - also there is some inconsequential Flash that takes some time to load on 56K)

http://www.totalfocus.org/sevensamples/

Thanks for taking the time to read this.
--Chuck :confused:

ahosang
04-24-2003, 01:20 PM
probably allowed to set href of an already written stylesheet.
Could try:
document.write the stylesheet into the haed conditionally according to which browser

jkd
04-24-2003, 08:59 PM
See here:
http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.html#StyleSheets-StyleSheet

It's a readonly attribute.

Alternatives:

document.getElementsByTagName("link").item(0).setAttribute("href", "something.css");

realisis
05-22-2003, 07:26 PM
just caught this thread:

use MS conditional comments - no javascript required:

<link rel="stylesheet" type="text/css" href="resources/sg7ns.css">

<!-- all browsers link to the above, only IE 5+ links to the below: declarations will offset those in the first stylesheet-->

<!--[if gte IE 5]>
<link rel="stylesheet" type="text/css" href="resources/sg7ie.css">
<![endif]-->



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum