Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to have proceed and cancel options on an pop-up or alert box.

Status
Not open for further replies.

kishore22

Technical User
Sep 25, 2002
12
US
Hi,
I need to open up a pop-up window or alert box, when an user clicks a link. I need to have two options on the alert box or pop-up window (Proceed and Cancel). If the user clicks the cancel button he will be on the same page, but if he clicks the proceed button he will redirect to other page.

thanx for help
Kishore
 
Use standard confirm() dialog: it has 2 buttons on it (OK and Cancel - and you cannot change their text!), this is very simple:

function askAndGo(url)
{
if (confirm('Click OK to proceed to next page.'))
document.location.href = url;
}

And call it like this:
<a href=&quot;somepage.html&quot; onclick=&quot;askAndGo(this.href)&quot;>some page</a>
or
<input type=&quot;button&quot; value=&quot;go to another one&quot; onclick=&quot;askAndGo('another.html')&quot;>
 
Alternativly, if you really want to have custom text... you can fake a pretty good alert using a popup (particularly in IE)... put something like this in the popup for a standard dialog style:
Code:
<style>
 BODY{ background-color: buttonface;
       border: 0x;
       scrolling: no;}
</style>
-gerrygerry

Standard response to one of my posts:
&quot;No where in your entire rantings did you come anywhere close to what can be considered a rational answer. We are all now dumber from having heard that. I award you no points and may God have mercy on your soul.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top