mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-20 23:56:20 +08:00
Add method for dynamic loading of a JavaScript file.
This commit is contained in:
parent
0b3e27b3fa
commit
48d3bc09f3
@ -722,3 +722,19 @@ PhoneGap.close = function(context, func, params) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Load a JavaScript file after page has loaded.
|
||||
*
|
||||
* @param {String} jsfile The url of the JavaScript file to load.
|
||||
* @param {Function} successCallback The callback to call when the file has been loaded.
|
||||
*/
|
||||
PhoneGap.includeJavascript = function(jsfile, successCallback) {
|
||||
var id = document.getElementsByTagName("head")[0];
|
||||
var el = document.createElement('script');
|
||||
el.type = 'text/javascript';
|
||||
if (typeof successCallback == 'function') {
|
||||
el.onload = successCallback;
|
||||
}
|
||||
el.src = jsfile;
|
||||
id.appendChild(el);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user