On Jun 3, 6:20 pm, "Thomas K. Nielsen" <thoni...@gmail .comwrote:
Hi I dynamically insert some stylesheets. I want them to be placed
before some javascript is executed. I know I can add an id to the
scripttag that I want the stylesheets to be insert above, but I then
You can try, but the HTML 4 specification doesn't include an id
attribute for script elements, so I would expect some browsers to not
support it.
In valid HTML, style elements should only appear in the head.
Browsers may take notice of script elements in the body, but the
results may not be what you expect).
have a problem with with backward compability(nee d to insert that id
to many pages) and I have a problem if my colleagues forget to add
that id to the script tag.
My question is can I locate a javascript funtion - ie I have a
initPage function that I know should
always be on the page - can I locate what script tag element that
function is located in and then use that to insert the stylesheets
above that script tag? How do I locate the script tag? I cannot be
sure that the script tag is always the last on the page.
Similar questions have been asked in the past, like "can a function
tell which script element it's in?" and the answer to that is a
qualified yes (search the archives). However, I don't think you can
do what you are after. If you explain a little further, you might get
a solution that suits.
I guess you want the style sheets added only if a particular function
is in the page. My suggestion would be to add the stylesheets to the
head using a function before calling your particular function (say
using your initPage function).
--
Rob