Forum Moderators: open

Message Too Old, No Replies

Java Redirection Problem

external java script

         

calmchess

5:21 pm on May 19, 2005 (gmt 0)

10+ Year Member



Will somebody plz tell me how to write the following script so it can run externally?

The link from my page to the script is not a problem.....the script doesn't seem to want to run externally for some reason though......It runs fine if i embed it in the page.

regards,
5th cup of java.

<script type="text/javascript" language="JavaScript">
document.write('<link type="text/css" rel="stylesheet" ');

if (screen.width <= 800 & navigator.appName=="Netscape" ){
document.writeln(' href="../../../../firefox800.css">'); }

else if (screen.width >= 1024 & navigator.appName=="Netscape" )
{document.writeln(' href="../../../../firefox1024.css">'); }

else if(screen.width <= 800 & navigator.appName=="Microsoft Internet Explorer" )
{document.writeln(' href="../../../../global.css">'); }
else (screen.width >= 1024 & navigator.appName=="Microsoft Internet Explorer" )
{document.writeln(' href="../../../../IE1024x768.css">'); }
</script>

Bernard Marx

6:47 pm on May 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A couple of errors:

1) Javascript boolean AND is && not & (that's binary AND)
2) The final else condition is missing an if

Assume you know that you don't use <script> tags inside external script files.

It's probably easier to do something like this:

var fileBaseName;

// ..code to choose from 'global', 'firefox800' etc..

Then :


document.writeln(
'<link type="text/css" rel="stylesheet" href="../../../../' + fileBaseName + '.css">'
);