I'm trying this: If jQuery is not present, add jQuery dinamically and test it with alert. But this doesn't works, ¿what I'm doing wrong?
HMTL:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml" id="crishk">
<head>
</head>
<body>
Welcome to Javascript Loader</a>
<div id="alertme">Alert me!</div>
<script type="text/javascript" language="javascript" src="dynamic.js"></script>
</body>
</html>
File dynamic.js
if (typeof jQuery == 'undefined') {
alert('You need to install jQuery to proceed.!');
var oHead = document.getElementsByTagName('head').item(0);
var oScript = document.createElement("script");
oScript.type = "text/javascript";
oScript.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js";
oHead.appendChild(oScript);
} else {
alert('jQuery is present...');
}
$(document).ready(function () {
alert($('#alertme').html());
});