Forum Moderators: open

Message Too Old, No Replies

DOM with JavaScript

DOM for external pages?

         

Emperor

5:59 pm on Oct 7, 2004 (gmt 0)

10+ Year Member



Hi guys,

I don't see a DOM forum so I'm posting this here.

I've been playing around with the DOM to get the hang of it, just counting elements and stuff like that so far; but it's pretty boring doing it with my own HTML documents so I was thinking of using pages on the web.

How can I do that? Maybe load the external page in a frame? Do I even have to display the page, maybe I can load it some other way?

In C++ I pull in the HTML document as text and put it in a block of memory, then I can do DOM stuff on it without even seeing what the page looks like in a browser; I was hoping I could do something like that with JavaScript.

Any help would be appreciated.

Bernard Marx

6:19 pm on Oct 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unfortunately/fortunately, this isn't possible. There is a security restriction on accessing framed pages from outside the main page's domain.
- You may be able to relax these security restrictions for trusted sites.

If you are just doing this for fun, you can still probe the DOMs of pages from the web with Javascript by other means.

1. Use XMLHTTPrequest object to download the document. This will only work if the page you are doing this from is local to your machine (even then more recent security changes may have changed that, dunno.)

2. (certainly in IE...) Use a bookmarklet to doc.create/head.appendChild a script tag on the webpage that sources a script on your machine.

3. (Win only) Use WScript to launch an instance of "InternetExplorer.Application" and navigate it to the webpage. You will have to do your probing in the WSH script.