Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When determining resolution do I need several sites 1

Status
Not open for further replies.

emcc

Programmer
Oct 12, 2001
124
US
I originally tried to code snippet below to try to reference a style sheet based on a users screen width:

if (screen.width>800) {document.write(&quot;<LINK REL... Src=\&quot;styleHighRes.css\&quot;>&quot;)}
else {document.write(&quot;<LINK REL... Src=\&quot;styleLowRes.css\&quot;>&quot;)}

I was successful accessing my desired style sheet but the original page that I wanted the style applied to, was covered up by a new page. The new page had whatever I specified in the document.write method, and not the original page hosting the javascript if statement.

Any suggestions to stop another page from opening up, and have the original page acquire the style specified in the style sheet?

Jeff
 
Hi emcc,
i responded to your other post, but heres the answer again.

if you put the following code immediately after the body tag you should have no problems...
ie

<head>
</head>
<body>
<script>
if (screen.width>1024) {document.write(&quot;<LINK rel=\&quot;stylesheet\&quot; href=\&quot;Framework1.css\&quot; type=\&quot;text/css\&quot;>&quot;)}
else {document.write(&quot;<LINK rel=\&quot;stylesheet\&quot; href=\&quot;Framework2.css\&quot; type=\&quot;text/css\&quot;>&quot;)}
</script>
...
</body>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top