...

View Full Version : javascript alert



ycpc55
01-06-2007, 11:39 PM
hi
i was wondering if there was anyway to take this code and make it so when you click ok it will take you to a url and also how can i add a cancel button thanks.

<script language="javascript">
alert("You have a chat invitation. Please goto 'Chat Partners Online!'");
</script>

david_kw
01-07-2007, 12:11 AM
This should do it.

if (confirm("Do you want to go?")) window.location.href = "http://www.google.com";

david_kw

ycpc55
01-07-2007, 12:40 AM
hi
thanks a lot that works :thumbsup:

ycpc55
01-07-2007, 02:17 AM
is there away to make this code open a new page?

if (confirm("Do you want to go?")) window.location.href = "http://www.google.com";

david_kw
01-07-2007, 03:02 AM
Try

if (confirm("Do you want to go?")) window.open("http://www.google.com", "NewWin");

see this link for information on window.open

http://www.javascript-coder.com/window-popup/javascript-window-open.phtml

david_kw

ycpc55
01-07-2007, 03:06 AM
again thank you!! :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum