Getting html page content in javascript

D

dk381

Hi,

I am wondering if I can use javascript to get a page content from a
URL.

What I am trying to do is that when a user clicks on a button, it goes
to the server and retrieve some texts and place it in a textarea.

Thanks in advance.
David


<HTML>
<HEAD>
<SCRIPT LANGUAGE= "JavaScript1.2">
function getPage( url ) {

//is there a way in javascript to get the content from a url
var content = Get the content of the given url?
alert( content );

}
</SCRIPT>
</HEAD>

<BODY>
<FORM>
<INPUT TYPE="button" VALUE="getpagecontent" onClick="getPage(
'http://www.someurl.com' );">
</FORM>
</BODY>
</HTML>
 
T

Tomasz Otap

dk381 said:
Hi,

I am wondering if I can use javascript to get a page content from a
URL.

What I am trying to do is that when a user clicks on a button, it goes
to the server and retrieve some texts and place it in a textarea.

Perhaps the XMLHTTP ActiveX Object can do it for ya? Here's some decent
info about using it for client-side http-requests in JavaScript:

http://jibbering.com/2002/4/httprequest.html

t
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top