Remote call in a JS file jquery.js will be IE8 under a strange question _javascript tips

Source: Internet
Author: User
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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.