views:

101

answers:

2

I have one problem. I have one button and one textarea in a frame.I want to show the source code in that textarea when I click on button. show source code of URL that I want to show.

help pleas!

A: 

Hi there You could try to send a request to that page and print the string you get back which mostly is a html-page.

//Edit

So with javascript you could send an Ajax Request to get the Html of another HTML-Page:

var myAjax = new Ajax.Request("google.com",  { method: 'get', onComplete: show_html});

On completion the method show_html will be called with the content of your requested url. This method could look like this:

function show_html( originalRequest ) {
    document.yourForm.yourTextArea.value = originalRequest.responseText;
}
I am using Javascript. I just want to view source code of other file in textarea. Thanks for your reply
chanthou
The cross-domain policy is going to prevent this.
Matti Virkkunen
A: 

You can use an XHR to request any URL on the same site as yours, but you won't be able to access external websites. The cross-domain policy prevents this for security reasons. If the site you'd like to access doesn't provide a JSONP (or similar) API, you can't do this on the client side. You'll have to use a server-side proxy.

Matti Virkkunen