About
javascript script in the browser
Articles Related
Management
Execution
Javascript code can be executed
Script
via the script html tag
Eval function
- via the eval function that evaluates a string as javascript
function globalEval( data ) {
if ( data && jQuery.trim( data ) ) {
// We use execScript on Internet Explorer
// We use an anonymous function so that context is window
// rather than jQuery in Firefox
( window.execScript || function( data ) {
window[ "eval" ].call( window, data );
} )( data );
}
}
On Attribute
- via the on… attribute of HTML element that handle the events
<button class="btn btn-info" onclick="console.log('1+1='+(1+1))" >1+1= ... </button>
For example, the following document fragment:
Asynchronous load and execution
- a Jquery with Ajax - Load and execute a JavaScript file.
$.ajax({
method: "GET",
url: "test.js",
dataType: "script"
});