PDA

View Full Version : VBscript Help


mikevaleriani
11-03-2002, 12:07 PM
:confused: Hello,
I am trying to set up a pop up window to give my visitors a choice before they can view the index page of my site. I tried to learn how to do that in the tutorial of this site, and everything works perfect except for the fact that the window doesn't open on its own. Visitors must click on a "click here" button in order to get the pop up window open. How do I clear that button and make the window open automatically as soon as the visitors arrive on that page? I know that it's something very silly and simple, but believe me, I have gone crazy so far and got nowhere :rolleyes:
You can view a page with the script at the following address: www.mikevaleriani.com/prova.html

Here is the script:

<script language="VBscript">
Sub entrance_onClick
returnvalue=MsgBox ("Would you like to listen to music while visiting this site?",36,"How About Some Music?")
If returnvalue=6 Then
window.location="http://www.mikevaleriani.com/frame_music.html"
Else
window.location="http://www.mikevaleriani.com/frame_main.html"
End If
End Sub
</script>
<script language="JavaScript">
function entrance2(){
if(navigator.appName!="Netscape")
return
if (confirm("Would you like to listen to music while visiting this site?"))
window.location="http://www.mikevaleriani.com/frame_music.html"
else
window.location="http://www.mikevaleriani.com/frame_main.html"
}
</script>

<form>
<input type="button" name="entrance" value="Click here" onClick="entrance2()">
</form>

Thank you so much to whoever can help me, I really appreciate that. :)

degsy
11-03-2002, 03:32 PM
Remove the sub for the button event.


<script language="VBScript" type="text/VBScript">

returnvalue=MsgBox ("Would you like to listen to music while visiting this site?",36,"How About Some Music?")
If returnvalue=6 Then
window.location="http://www.mikevaleriani.com/frame_music.html"
Else
window.location="http://www.mikevaleriani.com/frame_main.html"
End If


</script>

mikevaleriani
11-03-2002, 04:10 PM
Originally posted by degsy
Remove the sub for the button event.


<script language="VBScript" type="text/VBScript">

returnvalue=MsgBox ("Would you like to listen to music while visiting this site?",36,"How About Some Music?")
If returnvalue=6 Then
window.location="http://www.mikevaleriani.com/frame_music.html"
Else
window.location="http://www.mikevaleriani.com/frame_main.html"
End If


</script>


THANK YOU VERY MUCH! PROBLEM SOLVED :thumbsup:

mikevaleriani
11-03-2002, 05:17 PM
Thank you very much for your reply; it partly solved the problem. Now it warks very well on IE, but it still does the same thing on Netscape. Any idea how to solve the next one?
I am really greatfull to you, thank you very very much for your time, I really apreciated that.
Mike :thumbsup:

degsy
11-03-2002, 05:37 PM
Use <body onload="entrance2()">

Not sure why you are using VBScript as the Javscript will work for IE & NS.

mikevaleriani
11-03-2002, 08:27 PM
Originally posted by degsy
Use <body onload="entrance2()">

Not sure why you are using VBScript as the Javscript will work for IE & NS.

I use VBScript because this is what I found on the net. I am not familiar with these things, and it actually took me a while to find this. Do you know where I can find the same script in Java? I would be happy to make it work better if possible. If not, can you tell me where to place the script you sent me? Does it matter at all where I place it? Or does it have to be in a specific location?
Than you so much again for your prompt help. :thumbsup:

degsy
11-03-2002, 08:33 PM
Just use the Javascript method.
Start it by using onload="entrance()" in the body tag.


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<script language="JavaScript">
function entrance(){
if (confirm("Would you like to listen to music while visiting this site?"))
window.location="http://www.mikevaleriani.com/frame_music.html"
else
window.location="http://www.mikevaleriani.com/frame_main.html"
}
</script>

</head>

<body onload="entrance()">
</body>
</html>

mikevaleriani
11-04-2002, 08:04 AM
THANK YOU GOD!! Thank you - Thank you - Thank you! And Thank you again!! :thumbsup: :) :D