Solved

DOM & VBSCRIPT, Global Variable Problem

Posted on 1998-10-15
3
818 Views
Last Modified: 2009-12-16
I have these two DOM events, I would like the value of g_startTime to be the value from the onunload event but I am not sure how to make it global I have tried a <script> public g_startDate </script> but to no avail.  Basically what I am trying to do is time the interval in seconds between the loading and unloading of a web page.

<SCRIPT FOR=window EVENT=onload LANGUAGE="VBSCRIPT">
  Dim g_endTime
  window.status = "Page is loaded!"
  g_endTime = Now()
  MsgBox("Thanks")
  MsgBox("Start Time: " & g_startTime & " End Time: " & g_endTime)
  MsgBox( (DateDiff("s",g_startTime, g_endTime)) )
</SCRIPT>

<SCRIPT FOR=window EVENT=onunload LANGUAGE="VBSCRIPT">
  window.status = "Page is Unloaded!"
  g_startTime = Now()
  MsgBox("Start Time: " & g_startTime)
</SCRIPT>
0
Comment
Question by:sfranks
  • 2
3 Comments
 

Accepted Solution

by:
tgoglia earned 50 total points
ID: 1440159
You need to define a variable outside of any functions or subroutines to make it global. You can create a separate script tag to define global variables:
<script language="vbscript">
g_startTime=Now()
</script>


0
 

Expert Comment

by:tgoglia
ID: 1440160
I don't know if this the the actual code you are using, but there seems to be a little confusion in the naming of variables.The g_endTime variable is being set in the onload event and the g_startTime variable is being set in the onunload event.

0
 
LVL 1

Author Comment

by:sfranks
ID: 1440161
That is the code I am using and it is correct.   What I want is the time it takes for the page to load.  The onload event fires after the page is done loading.  The onunload event fires when an URL is executed (when the request for the document is sent to the server) so I want the time between the onunload and the onload unfortunately VBs time functions lowest denominator is seconds which unfortunately is not precise enough.  I am therefore going to have to use Jscript.  
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now