Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help with JScript Problem (http.open) to Time a Webpage Read

Status
Not open for further replies.

eze2007

Programmer
Joined
Jan 27, 2006
Messages
1
Location
CA
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>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top