Forum Moderators: open

Message Too Old, No Replies

how to show new window after confirm()?

         

fukchai2000

2:26 am on Feb 10, 2005 (gmt 0)

10+ Year Member



hi guys,

i tried to redirect user to "some site" in a new window after they click OK,
and didnt do anything when they click CANCEL (remain in the same page).
how can i do it?
function some_function(some_site)
{
if (confirm("yes no"))
{
window.location=some_site;
}
else
{
quit();
}
}
i used this function....is it a proper function?(i just can't get it work) help me plz...

rocknbil

5:56 pm on Feb 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't need to specifically exit the program. Just do what you want and do nothing if nothing is what you want. :-) This is probably not a **great** solution because it's Javascript-dependent.

<html><head><title></title></head>
<body>
<form>
<input type="button" onClick="some_function('http://www.example.com');" value="Go to Monkeys Rule The World">
</form>
<script language="javascript">
function some_function(some_site) {
var confirmed = confirm("Do you want to go to Monkeys Rule The World dot com?")
if (confirmed == true) {
var day = new Date; // These insure a unique window each
var id = day.getTime(); // time one is opened (instead of same window)
var params = 'width=400,height=500,scrollbars,resizable';
var win = open(some_site,id,params);
}
//Note there's no 'else.' The above only happens if OK is selected.
}
</script>

</body>
</html>