Solved

DOM & VBSCRIPT, Global Variable Problem

Posted on 1998-10-15
3
811 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

743 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

16 Experts available now in Live!

Get 1:1 Help Now