471,831 Members | 764 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,831 software developers and data experts.

Timer or button to launch VB script?

118 100+
I am making a CD based website. I have made the code to open the CD tray... (below)

Expand|Select|Wrap|Line Numbers
  1.  
  2. <SCRIPT LANGUAGE="VBScript">
  3. <!--
  4.  
  5. Set oWMP = CreateObject("WMPlayer.OCX.7" )
  6. Set colCDROMs = oWMP.cdromCollection
  7.  
  8. if colCDROMs.Count >= 1 then
  9.         For i = 0 to colCDROMs.Count - 1
  10.                 colCDROMs.Item(i).Eject
  11.         Next ' cdrom
  12. End If
  13.  
  14. -->
  15. </SCRIPT>
  16.  
This code has to be placed in the <head> tag but will execute automatically on the loading of the page. Is it possible to set a timer for it to execute after 60 seconds, for example; or on the click of a button?

Thanks,

Sam
Apr 26 '07 #1
2 2054
AricC
1,892 Expert 1GB
I am making a CD based website. I have made the code to open the CD tray... (below)

Expand|Select|Wrap|Line Numbers
  1.  
  2. <SCRIPT LANGUAGE="VBScript">
  3. <!--
  4.  
  5. Set oWMP = CreateObject("WMPlayer.OCX.7" )
  6. Set colCDROMs = oWMP.cdromCollection
  7.  
  8. if colCDROMs.Count >= 1 then
  9.         For i = 0 to colCDROMs.Count - 1
  10.                 colCDROMs.Item(i).Eject
  11.         Next ' cdrom
  12. End If
  13.  
  14. -->
  15. </SCRIPT>
  16.  
This code has to be placed in the <head> tag but will execute automatically on the loading of the page. Is it possible to set a timer for it to execute after 60 seconds, for example; or on the click of a button?

Thanks,

Sam
This seems like more of a Javascript question or are you trying to do this with VB Script?
Apr 26 '07 #2
helraizer1
118 100+
I was thinking of a button or a timer to launch the code. Using either HTML or Javascript but I'm not sure how to do it. For instance, in a Javascript script the function has a name such as: "function1()" so then you can say using HTML:

<input type="button" onClick="function1()">
-or-
<Body onload="function1()" onunload="stoptimer()"> etc...

But for the VBScript I don't know how to execute it with a button using HTML or Javascript. At the moment when it is in the <head> of my site it executes the script as it loads the page.

Any ideas?

Sam
Apr 26 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.