The ASP that cause me trouble is running on IIS that set ASP default language to JScript instead of VBScript.
This ASP page is popped up by another ASP page and there are authentication, privilege and security stuff involved. And yes this page contain a lot of javascript.
there is a <DIV></DIV> in this page for me. And my job is as simple as put another page between that tag.
Yes it's that easy. It like ... I love your web site and I want to show your homepage of your website in the middle of my page.
and I found this script on the internet
Expand|Select|Wrap|Line Numbers
- <%
- 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
- 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)
- %>
- <html>
- <body>
- </body>
- </html>
I found another script on another website that help me use both jscript and vbscript using 2 .asp
the first asp is page1.asp
Expand|Select|Wrap|Line Numbers
- <html>
- <title>My page</title>
- <body>
- <script language="javascript" src="page2.asp"></script>
- </body>
- </html>
the secondpage asp is page2.asp
Expand|Select|Wrap|Line Numbers
- <%@ language="VBScript"%>
- <%
- strPage = "Hello"
- %>
- document . write ("<%=strPage%>")
So I tried to put the first script I found in the first website in the page2.asp like this
page2.asp
Expand|Select|Wrap|Line Numbers
- <%@ language="VBScript"%>
- <%
- 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
- 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)
- %>
- document . write ("<%=strPage%>")
I tried to use Response.write it doesn't work too.
so I tried a fews other things too.
1. after statement
strPage = GetWebPage( "http://www.livio.net/main/default.asp", "" )
I tried
strPage = Len(strPage)
and it show a number on my page then I think this is not far from the answer.
I tried
strPage = Mid(strPage, 100, 10)
and it show some string on my page
I found out that in fact this strPage is a string that have a lot of double quote in it and that seem to be a lot of trouble for document . write
so my question are
1. Why Response.Write (strPage) did not work in this case?
2. document . write ("<%=strPage%>") seem to work with out double quote, how ca i fix it?
3. Is there other ways to do this?