Copy Code code as follows:
function include (path) {
var a=document.createelement ("script");
A.type = "Text/javascript";
A.src=path;
var head=document.getelementsbytagname ("head") [0];
Head.appendchild (a);
}
Include ("Http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js")
This script you down in the IE8, in the IE8 address bar under the press ENTER after the call jquery's image, method of what is not a problem, but after refreshing there is a problem. is to refresh whatever happens after you click Enter in the Address bar.
There is no problem with Firefox. With a window.name HTML script, you can test:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>demo: cross-domain </title>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<script>
function include (path) {
var a=document.createelement ("script");
A.type = "Text/javascript";
A.src=path;
if (A.readstatus = = 200) {
var head=document.getelementsbytagname ("head") [0];
Head.appendchild (a);
//}
}
Include ("Http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js")
</script>
<script>
$ (function () {
function SendData (URL, callback) {
if (!url | | typeof URL!== ' string ') {
Return
}
url = = (Url.indexof ('? ') > 0? ' & ': '? ' + ' windowname=true ';
var frame = $ (' <iframe style= ' Display:none; " ></iframe> '). Appendto ("body");
var state = 0;
var clear = function () {
try{
Frame[0].contentwindow.document.write ('); Clear the contents of the IFRAME
Frame[0].contentwindow.close ()//Avoid IFRAME memory leaks
Frame.remove ();//delete iframe
}catch (e) {}
};
var getData = function () {
try{
var data = Frame[0].contentwindow.name;
}catch (e) {}
Clear ();
if (callback && typeof callback = = ' function ') {
callback (data);
}
};
Frame.bind (' Load ', function () {
if (state = = 1) {
GetData ();
else if (state = = 0) {
state = 1;
Frame[0].contentwindow.location = "none.html";
}
});
frame[0].src = URL;
}
Application:
var testurl = ' http://www.jb51.cn/test.html ';
$ ("button"). Click (function () {
SendData (Testurl, function (result) {
var Fishdiv = $ ("#oldFish");
Fishdiv.html ("The data You obtain is:" +result);
})
})
})
</script>
<body>
<button> Remote Loading Data </button>
<div id= "Oldfish" ></div>
<p style= "FONT-SIZE:12PX;" >dev by <a href= "http://www.jb51.cn" > Material downloads </a> & Birch </p>
<p style= "FONT-SIZE:12PX;" > Reference: <a href= "Http://www.jb51.net" > Yun-Habitat Community </a></p>
</body>