ahosang
01-27-2003, 02:03 PM
I participate on another forum and a user there has a problem. I'll reprint the problem exactly.
<problem>
I have a number of XHTML pages that I need to include some content in using JavaScript. (It has to be with JavaScript as it adds a style sheet that hides a menu, if users without JavaScript come to the page it is essential that the styles do not get applied).
My code:
if (document.getElementById) {
document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/js.css\" media=\"screen\" />")
}
This works fine in a document servered as text/html, but in order to take advantage of Mozilla's XML parser I serve XHTML pages as application/xhtml+xml (which they should be served as) if the browser claims it supports that content type.
Now - how do I get this to work with the browser rendering XHTML instead of tag soup?
I do not want a flash of unstyled content (and some of the pages have a lot of content in them so there will be such a flash if the script is called using onload).
</problem>
I don't mind anyone going there and helping the guy and getting the kudos themselves, but as you know it's against forum rules to advertise another forum. If anybody(Alex, jkd or anybody for that matter) wants to e-mail me for address, you're welcome. I can't suggest that he comes here because that's against site rules over there obviously.
He's a good chap and I'd like to help him. It makes me learn as well. Obviously I'll liase with him regarding comments made here, as it's not my dilemma and I don't know the full ins and outs of it.
If there is any problem with this, please moderators, e-mail me!
<problem>
I have a number of XHTML pages that I need to include some content in using JavaScript. (It has to be with JavaScript as it adds a style sheet that hides a menu, if users without JavaScript come to the page it is essential that the styles do not get applied).
My code:
if (document.getElementById) {
document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/js.css\" media=\"screen\" />")
}
This works fine in a document servered as text/html, but in order to take advantage of Mozilla's XML parser I serve XHTML pages as application/xhtml+xml (which they should be served as) if the browser claims it supports that content type.
Now - how do I get this to work with the browser rendering XHTML instead of tag soup?
I do not want a flash of unstyled content (and some of the pages have a lot of content in them so there will be such a flash if the script is called using onload).
</problem>
I don't mind anyone going there and helping the guy and getting the kudos themselves, but as you know it's against forum rules to advertise another forum. If anybody(Alex, jkd or anybody for that matter) wants to e-mail me for address, you're welcome. I can't suggest that he comes here because that's against site rules over there obviously.
He's a good chap and I'd like to help him. It makes me learn as well. Obviously I'll liase with him regarding comments made here, as it's not my dilemma and I don't know the full ins and outs of it.
If there is any problem with this, please moderators, e-mail me!