I have been searching for this for hours, found many ways but no idea why doesn't any of them works..
code :
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="js/test.js"></script>
</head>
<body>
<label id="res"></label>
<script type="text/javascript">
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
function crypt() {
var ex = getParameterByName('eX');
var er = getParameterByName('eR');
var aaa = Aes.Ctr.encrypt(ex, er, 256)
document.write(aaa);
document.getElementById('res').innerHTML = aaa;
}
window.onpaint = crypt();
</script>
</body>
</html>
What i'm trying to do is to read params from the URL and then run some JavaScript code using these params, then print result in the page.
tried to put the JS code in head, tried onload event, tried addeventlistner, and other stuff, still no luck(on HTML and ASP). all works after page load completes.
but it must be done before page loads completely..
Thanks.