Forum Moderators: open
So I have to include his entire page as a part of my page (I want to keep everything else on my page intact)
My page uses asp and javascript. My page and my friend page are on the different domain.
I tried to read html on my friend page using example on the internet
<%@ language="VBScript"%>
<html>
<%
Private Function GetWebPage(ByVal HTTPAddress, ByVal CharSet)
Dim strContent, xml_http, strBody, strText, max
'--- Fetch the web page
On error resume next
Set xml_http = Server.CreateObject("Microsoft.XMLHTTP")
xml_http.Open "GET", HTTPAddress, False
xml_http.Send
If Err Then
GetWebPage = ""
Exit Function
End If
strContent = xml_http.responseBody
Set xml_http = Nothing
On Error GoTo 0
'--- Converts the binary content to text
'--- Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
'--- Specify stream type - we want To save text/string data.
BinaryStream.Type = 1
'--- Open the stream And write text/string data To the object
BinaryStream.Open
BinaryStream.Write strContent
'--- Change stream type To binary
BinaryStream.Position = 0
BinaryStream.Type = 2
'--- Specify charset For the source text (unicode) data.
If Len(CharSet) > 0 Then
BinaryStream.CharSet = CharSet
Else
BinaryStream.CharSet = "UTF-8"
End If
'--- Open the stream And get binary data from the object
strText = BinaryStream.ReadText
'--- remove headers
max = InStr(1, strText, Chr(10) & Chr(10), 1)
GetWebPage = Mid(strText, max + 1)
End Function
%>
<body>
<%
Dim strPage
strPage = GetWebPage( "http://www.livio.net/main/default.asp", "" )
'--- get the html source of the livio.net home page and store it into the variable strPage.
Response.Write (strPage)
%>
</body></html>
it work fine except that I use javascript not vbscript
I tried to use
<HTML>
<HEAD>
<TITLE> Include Page </TITLE>
<SCRIPT LANGUAGE="JScript">
// new prototype defintion
document.include = function (url) {
if ('undefined' == typeof(url)) return false;
var p,rnd;
if (document.all){
// For IE, create an ActiveX Object instance
p = new ActiveXObject("Microsoft.XMLHTTP");
}
else {
// For mozilla, create an instance of XMLHttpRequest.
p = new XMLHttpRequest();
}
// Prevent browsers from caching the included page
// by appending a random number
rnd = Math.random().toString().substring(2);
url = url.indexOf('?')>-1? url+'&rnd='+rnd : url+'?rnd='+rnd;
// Open the url and write out the response
alert("1");
p.open("GET",url,false);
alert("2");
p.send(null);
document.write( p.responseText );
}
</SCRIPT>
</HEAD>
<BODY>
<script>
document.include('http://www.livio.net/main/default.asp');
</script>
</BODY>
</HTML>
it work fine if I call this from [localhost...] or [127.0.0.1...] or [myComputerName...]
but it doesnt work on [192.168.0.100...] or [myName.Mycompant.local...]
I have include "192.168.0.100 myName.Mycompant.local" in my host file
and 192.168.0.100 is my ip address
when I say it doesnt work it does do alert("1") but not alert("2"). So it must be p.open("GET",url,false); that cost the problem. and it does say permission denied.
please help.
or is there any other way to fix my problem please tell me.
Thanks