aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How can i include .css file by using java script based on the browser...? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How can i include .css file by using java script based on the browser...?" Watch "How can i include .css file by using java script based on the browser...?" New topic
Author

How can i include .css file by using java script based on the browser...?

Lakshmi Rudraraju
Greenhorn

Joined: Mar 26, 2001
Posts: 3
I am trying to call two different style sheet depending on the browser from Java script....? I am trying to call it by putting the link tag in document.write() function... The Example code is as follows, but it is not working... Can any body tell me what function do i have to use....?

function abc()
{
if (navigator.appName == "Netscape")
{
document.write("<link rel='stylesheet' src='/discounting/discounting.css' href='/discounting/discounting.css' type='text/css'> ");
}
}

Thank You
Lakshmi.
manav k
Greenhorn

Joined: Oct 30, 2000
Posts: 19
well simply because it is too late to load the css file, the page has loaded before the script has executed, what you can try to do is
1) put the script inside the <head></head> tags and see if it works
2)calculate the target file name for the css in the parent frame (that defines the frames) and then in the current frame use the pre calculated filename to load the css file.
manav
manav k
Greenhorn

Joined: Oct 30, 2000
Posts: 19
and also use ../ before your href
href='../discounting/discounting.css'
-manav
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can i include .css file by using java script based on the browser...?
 
Similar Threads
help needed with mouse over text change
Calling ActiveX method in NetScape
Undefined in alert dialog box
Struts action class call from java script
tabs and subtabs