2

Lets say for example i have an google search results page opened in a window or a tab in firefox.Is there a way i can retrieve the html code of that tab or window using javascript? I suppose that the webpage html is saved temporarily somewhere in computer memory. Can i load the webpage using memory saved address? Is there a way for javascript to read html files saved in the same folder as the original?For example i have saved the webpage in a folder on my computer.If i create an html file inside the same folder does javascript consider the saved webpage as the same domain?

6
  • What you would need is some server-side code that will retrieve the other site's code for you to manipulate. JavaScript can't do it for you (unless the user explicitly and foolishly opens up that security hole for you). Commented Dec 20, 2011 at 17:27
  • @mblase75 i dont want to server side code.everything must happen inside the browser.what do you mean the user open up the security hole?lets say the user wants this security hole ,how can he open it? Commented Dec 20, 2011 at 17:30
  • The OTHER site has to ask the user to grant permission. Do you control both sites? If not, you're out of luck without using server-side code. Commented Dec 20, 2011 at 17:33
  • No. JavaScript lives and dies within the browser. It does not have access to the file-system. Commented Dec 20, 2011 at 17:39
  • @gurung html5 enabled have access to file system using the FILE api html5rocks.com/en/tutorials/file/dndfiles Commented Dec 20, 2011 at 18:12

2 Answers 2

1

No, you most certainly can't do that unless you control both pages. This would be a huge security hole.

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

Comments

0

There is a custom search API which may help if you specifically want to do Google searches. It appears to have a JSONP implementation which should let you make a cross-domain request, but I haven't tried it out so I'm not sure how well it works.

1 Comment

google search results is just example.i want to be able to save the webpage html code on a file using a script and retrieving the html code from another html file saved in the same folder

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.