Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DOM & VBSCRIPT, Global Variable Problem

Posted on 1998-10-15
3
Medium Priority
?
854 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 150 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

604 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