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?
-
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).Blazemonger– Blazemonger2011-12-20 17:27:39 +00:00Commented 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?vkefallinos– vkefallinos2011-12-20 17:30:59 +00:00Commented 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.Blazemonger– Blazemonger2011-12-20 17:33:52 +00:00Commented Dec 20, 2011 at 17:33
-
No. JavaScript lives and dies within the browser. It does not have access to the file-system.Bhesh Gurung– Bhesh Gurung2011-12-20 17:39:45 +00:00Commented Dec 20, 2011 at 17:39
-
@gurung html5 enabled have access to file system using the FILE api html5rocks.com/en/tutorials/file/dndfilesvkefallinos– vkefallinos2011-12-20 18:12:40 +00:00Commented Dec 20, 2011 at 18:12
|
Show 1 more comment
2 Answers
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
vkefallinos
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