RSS

Finding HEAD Information through Java Script?

I want to write a Simple Script that will take a piece of Content in the exisiting page and pop it out as another window.

I am able to get the content (through DOM) and open a new window and write it. How ever the original Page has lots of styling(externalized into CSS) and some script (externalized into JS file) and added in the HEAD section of the document.

All I need to know is through javascript how do I get the external entities (CSS, JS) referred by a document? If I get this information, I could simply use the same in my popped up window and be a happy camper!

Thanks,

Rave
Thanks for the links Ben.

I found the answer in the links you posted.

So to summarize, stylesheets can be accessed by document.styleSheets[] and scripts can be accessed by document.scripts[] .

I dont know how to start at HEAD through HTML DOM as stated by the other person.


2 Responses to “Finding HEAD Information through Java Script?”

  1. Ben P says:

    The JavaScript Source website has a DOM browser. The script displayed on this page: http://javascript.internet.com/page-details/dom-browser.html , shows you an example of all the DOM top level objects. I notice that one of the top level objects is called “scripts” and another is “styleSheets”. This would seem to be exactly what you need.

    I’m sure you will be able to deduce the answer from the source code provided. You could also try this walk through on the Mozilla developer website: http://developer.mozilla.org/en/docs/Traversing_an_HTML_table_with_JavaScript_and_DOM_Interfaces

    Good luck!

  2. Jake Cigar says:

    start at your head , and loop thru the children anything that you want to be in the new window gets copied!

    DOM da DOM DOM DOM!

    Its pretty easy in your case because your code is in js and css files!

Leave a Reply