I am trying to track how long a reader reads a webpage on my site for stastical reasons.
I am trying to build a script that updates the mySQL database with the time duration for reading the page (var milDiff ).
The JS Console doesn't like my http.open('GET' command - keeps denying my persmisson to it I don't know why
Error: uncaught exception: Permission denied to call method XMLHttpRequest.open
All the scripts reside under the same domain name on the same webserver
any advice?
Here is my first attempt at anything remotely AJAX:
<html>
<head>
<title>Test Page</title>
<script type='text/javascript'>
var startTime = null;
window.onload = function () {
startTime = new Date();
}
window.onunload = function ( ) {
var endTime = new Date();
var milDiff = Math.abs(startTime - endTime);
alert( milDiff );
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
http = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
http = new ActiveXObject("Microsoft.XMLHTTP");
}
http.open('GET', ' +milDiff, true);
http.onreadystatechange = function() {
if (http.readyState == 4) {
document.getElementById('some_div_id').innerHTML = http.responseText;
}
}
}
</script>
</head>
<body >
</body>
</html>
I am trying to build a script that updates the mySQL database with the time duration for reading the page (var milDiff ).
The JS Console doesn't like my http.open('GET' command - keeps denying my persmisson to it I don't know why
Error: uncaught exception: Permission denied to call method XMLHttpRequest.open
All the scripts reside under the same domain name on the same webserver
any advice?
Here is my first attempt at anything remotely AJAX:
<html>
<head>
<title>Test Page</title>
<script type='text/javascript'>
var startTime = null;
window.onload = function () {
startTime = new Date();
}
window.onunload = function ( ) {
var endTime = new Date();
var milDiff = Math.abs(startTime - endTime);
alert( milDiff );
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
http = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
http = new ActiveXObject("Microsoft.XMLHTTP");
}
http.open('GET', ' +milDiff, true);
http.onreadystatechange = function() {
if (http.readyState == 4) {
document.getElementById('some_div_id').innerHTML = http.responseText;
}
}
}
</script>
</head>
<body >
</body>
</html>