// Load JS Dynamically after click on button
<html>
<head>
<title>Load JS Dynamically</title>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script type="text/javascript">
function loadjs(){
var url="newscript.js";
$.getScript(url, function() {
alert('JS Load Successfully');
});
}</script>
</head>
<body>
<input type="button" name="load" value="Load JS" onclick="loadjs()">
</body>
</html>
<head>
<title>Load JS Dynamically</title>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script type="text/javascript">
function loadjs(){
var url="newscript.js";
$.getScript(url, function() {
alert('JS Load Successfully');
});
}</script>
</head>
<body>
<input type="button" name="load" value="Load JS" onclick="loadjs()">
</body>
</html>
Note:Please load js put in your project folder not load any server js directly because of server js take much time for load.
No comments:
Post a Comment