• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Lakshmi Rudraraju
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and also use ../ before your href
href='../discounting/discounting.css'
-manav
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic