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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confirm / Redirect script not working

Status
Not open for further replies.

TheDust

Programmer
Aug 12, 2002
217
US
For years I've used this script and it worked just fine. I'm not developing a site on a new server (that shouldn't have anything to do with the problem). Check it out:

Code:
function confirmation(message, url) {
    if (confirm(message)) {
		window.location = url;
    } else {
		return false;
	}
}

The user clicks to delete an object and if he/she confirms the deletion, they are taken to the url provided. However, what is happening is that pressing "OK" gives the same result as "Cancel". Nothing happens. What is up with that? This is how it's being included in the HTML:

Code:
<script language="javascript" src="/path/to/main.js"></script>

<a href="#" onclick="confirmation('Are you sure?', '[URL unfurl="true"]http://www.urlhere.com')">DELETE</a>[/URL]

Any ideas? This is just crazy...
 
simple!

Code:
<a href="#" onclick="[red]return [/red]confirmation('Are you sure?', '[URL unfurl="true"]http://www.urlhere.com')">DELETE</a>[/URL]



*cLFlaVA
----------------------------
spinning-dollar-sign.gif
headbang.gif
spinning-dollar-sign.gif

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Thanks, cLFlaVA! I think the actual problem was caused by some needless Javascript my designer stuck in one of the table cells that was taking precedence over my code. However, I like your code better than mine so I'm sticking with it. Works like a charm now. Thanks again! Cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top