The problem you are going to have is knowing when the user exits the browser
or leaves the page that each video is on. When the user leaves the page, you
could redirect somewhere else to do that database recording, but when they
close the browser, this isn't possible. (I don't think) Since the window
onunload scripts are all client side also, the cannot hit the database
(unless you start putting direct client access to the database on the site,
which is something you probably don't want. ) So you have 2 problems,
recording the data you want to capture, and storing the data into the
database.
You could record the data in user cookies. So you could have a client side
javascript block like: (this is freehand coded.. probably has syntax errors
and such:
<SCRIPT>
var video_number = 1;
window.onload = function(e)
{
var now = new Date()
createCookie("Load" + video_number,now.GetTime(),365);
}
window.onunload = function(e)
{
var now = new Date()
createCookie("Unload" + video_number,now.GetTime(),365);
}
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
</SCRIPT>
This coded will save the data.
When the next video loads, you could then check all the user's cookies to
audit them:
<%
For x = 1 to Request.Cookies.Count
if instr(Request.Cookies.Key(x),"Load") > 0 then
videoNum = cLng(replace(request.cookies.Ken(x),"Load","")
unloadTime = cDate(request.Cookies(request.cookies.key(x))
' Store this in database
else if
instr(Request.Cookies.Key(x),"Unload") > 0 then
videoNum = cLng(replace(request.cookies.Ken(x),"Unload","")
loadTime = cDate(request.Cookies(request.cookies.key(x))
' Store this in database
end if
end if
next
%>
You could also force users to an audit page that will record all the cookies
to the database and then let them know if they "passed" or not.
Hope this helps, it's early in the morning, so I'm sure my code needs a lot
of work, but I hope you get the idea.
Steve
"No Spam Please" <RJ*******@aol.com> wrote in message
news:gj*********************@news4.srv.hcvlny.cv.n et...
Let me explain more on what I am doing.
The login form takes the user to a webcast framed template. From that
template they have 9 videos listed. All videos are manditory viewing and
we need to verify that they had the page open (video is embedded on the page)
based on number of minutes on the page. I would like to track how much
time is spent on each video.
Structure looks like this:
Login.asp goes to:
clip1/wm_player_frameset.asp
from here the user can select 8 other videos which goes to
clip2/wm_player_frameset.asp
clip3/wm_player_frameset.asp
clip4/wm_player_frameset.asp
clip5/wm_player_frameset.asp
clip6/wm_player_frameset.asp
clip7/wm_player_frameset.asp
clip8/wm_player_frameset.asp
clip9/wm_player_frameset.asp
The database has fields called:
firstn
lastn
VZID
currDate
currTime
clip1
clip2
clip3
clip4
clip5
clip6
clip7
clip8
clip9
I would like to populate those fields (clip#) with the number of minutes
spent at each wm_player_frameset.asp page
I know I have to also pass at least the ID field value between pages.
I was able to find a script that assigns the number of minutes on the page
to a varable (see below). I can call that varable clip1, clip2, clip3...
in each wm_player_frameset.asp file but I don't know how to have the OnUnload
write the varable to the database.
<SCRIPT LANGUAGE="Javascript">
pageOpen = new Date();
function timeon() {
pageClose = new Date();
minutes = (pageClose.getMinutes() - pageOpen.getMinutes());
{
clip1 = (minutes);
}
}
// End -->
</SCRIPT>
</HEAD>
<BODY OnUnload="timeon()">
Thanks
Rich