Solved

DOM & VBSCRIPT, Global Variable Problem

Posted on 1998-10-15
3
842 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

717 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