Copy Code code as follows:
Front desk
<div id= "Showiframe" ></div>
$ (document). Ready (function () {
var url = "@Url. Action (" getpagehtml "," Catalog ")";
$.ajax ({
Url:url,
Type: "POST",
DataType: "JSON",
Data: {URL: "http://www.baidu.com"},
Error:function () {
Alert ("BBB");
},
Success:function (data) {
$ ("#showIframe"). Append (data);
$ ("#showIframe div"). Hide ();
$ ("#showIframe > #container"). Show ();
$ ("#showIframe > #container > #content"). Show ();
$ ("#showIframe > #container > #content >.cmspage"). Show ();
}
});
});
Background
Reptilian nature, send URL request, return entire page HTML
[HttpPost]
Public jsonresult getpagehtml (string url)
{
String PageInfo;
Try
{
HttpWebRequest Myreq = (HttpWebRequest) httpwebrequest.create (URL);
Myreq.accept = "Image/gif, Image/x-xbitmap, Image/jpeg, Image/pjpeg, Application/x-shockwave-flash, application/ Vnd.ms-excel, Application/vnd.ms-powerpoint, Application/msword, */* ";
Myreq.useragent = "mozilla/4.0" (compatible; MSIE 6.0; Windows NT 5.1; SV1. NET CLR 2.0.50727) ";
HttpWebResponse Myrep = (HttpWebResponse) myreq.getresponse ();
Stream MyStream = Myrep.getresponsestream ();
StreamReader sr = new StreamReader (MyStream, Encoding.default);
PageInfo = Sr. ReadToEnd (). ToString ();
}
Catch
{
PageInfo = "";
}
Return Json (PageInfo);
}