0

This is what I've tried:

function createDocumentz() {
    var doc = document.implementation.createHTMLDocument('http://www.moviemeter.nl/film/270',null,'html');
    return doc;
}

Even though a document gets created, if I run this with Firebug it says that the body node has no childnodes, any idea why?

2
  • Because you haven't appended any to body. Commented Mar 18, 2013 at 11:00
  • Maybe this question can help. Commented Mar 18, 2013 at 11:05

2 Answers 2

0

Looks like you assume that you can use createHTMLDocument() to download and parse a HTML file from the URL you've passed as the first parameter. That is not the case, createHTMLDocument() always creates an empty document.

Also, the parameters you've passed to the function are those of createDocument(). createHTMLDocument() takes only one parameter, the document title. But even if you'd use createDocument(), the first parameter is the URI of the namespace, not the source document.

Unfortunately there's no way to download and manipulate external web site's HTML using JavaScript alone. The closest you can get is displaying the document in an iframe.

Sign up to request clarification or add additional context in comments.

1 Comment

It's now possible to download and manipulate the document. You can't, however, set it's Document.URL unfortunatelly.
0

No, you cannot get the content from another website, this way.

If it did, it would have lead to cross site scripting.

All you would get is an empty document, due to the browser's policy, which of course has an empty body.

You can use an Iframe & set the source to the same...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.