Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I need to import HTML file of any website on the choice of user using Javascript or jQuery into another file which i can run locally.

share|improve this question
1  
you can only get the html from a page on the same server as your page was loaded from. Fetching from another server is called cross site scripting or XSS in short and the browsers blocks XSS –  Rune FS May 27 at 7:40
 
What do you mean import HTML? Do you want to download the source of a random website? –  GEMI May 27 at 7:41
 
Sounds like something easily fixed by reading a manual. –  Gung Foo May 27 at 7:41
 
Here i need the HTML file of website so that i can validate. –  jerin john May 27 at 9:11
 
Best way to download a webpage's source html –  jerin john May 27 at 12:23

closed as not a real question by Gung Foo, undefined, Jan Dvorak, flavian, Mooseman May 27 at 11:38

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

You can use the jquery .load() function for that.

http://api.jquery.com/load/

Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol.

share|improve this answer
1  
not really since you can't load the content from another server using JS –  Rune FS May 27 at 7:42
 
Thanks @RuneFS I edited my answer. –  veelen May 27 at 7:52

The Same Origin Policy makes this tricky to accomplish, but you can do it by deploying a rewriting http proxy that will external pages appear as if they are coming from the same origin as your own page.

Edit:

About.com has a list of rewriting proxy servers.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.