Remotely calling jquery. js in a js file will cause a strange problem in ie8 _ javascript skills

Source: Internet
Author: User
You can call this script in ie8, press enter in the address bar of ie8, and then call jquery's object and method. However, there is a problem after refreshing. After refreshing, press enter in the address bar. The Code is 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 ();
}
Include ("http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js? 1.1.9 ")


You can call this script in ie8, press enter in the address bar of ie8, and then call jquery's object and method. However, there is a problem after refreshing. After refreshing, press enter in the address bar.
There is no problem under Firefox. The following is an html Script For window. name. You can test it:

The Code is as follows:





Demo: Cross-Origin

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 ();
//}
}
Include ("http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js? 1.1.9 ")
Script
Script
$ (Function (){
Function sendData (url, callback ){
If (! Url | typeof url! = 'String '){
Return;
}
Url + = (url. indexOf ('? ')> 0? '&':'? ') + 'Windowname = true ';
Var frame = $ (''). appendTo (" body ");
Var state = 0;
Var clear = function (){
Try {
Framework0).contentdomaindoc ument. write (''); // clear iframe content
Frame [0]. contentWindow. close (); // prevent iframe Memory leakage
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 obtained is:" + result );
})
})
})
Script


Remote Data Loading


Dev By material download & Hua


Reference: foot home



Related Article

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.