Reputation: 662
<script type="text/javascript ">
<body onLoad="timeTracker._recordStartTime();">
<body onunload ="timeTracker._recordEndTime(); timeTracker._track(pageTracker);"
</script>
I am trying to use this code to record the time interval between load and unload of a page.
Unfortunately, it does not work. Why?
Upvotes: 0
Views: 2398
Reputation: 348992
You may only specify one <body>
tag. Also, it's not possible in HTML to specify plain HTML tags inside script tags.
Either add the handler through JavaScript, or merge the attributes in one <body>
-tag. JavaScript is case-sensitive, so you should use window.unload
(lowercase) instead of window.onLoad
.
Use:
<script>
window.onload = function() {
timeTracker._recordStartTime();
};
window.onunload = function() {
timeTracker._recordEndTime();
timeTracker._track(pageTracker);
};
</script>
OR (without <script>
tags):
<body onLoad="timeTracker._recordStartTime();" onunload ="timeTracker._recordEndTime(); timeTracker._track(pageTracker);">
Upvotes: 6