Link Conformation Using JavaScript

Here’s a simple javascript code I wrote for link conformation. What is does is when you want to tell someone that they are going to another portion of your site thats secured and will require a password, an archived and out dated version of the site, or display a warning to the user before downloading a copyrighted file from your site.

function disp_confirm(location) {
	var r=confirm("Conformation Message n Second line of message.");
	if (r==true) {
		window.open(location);
	}
	else {
	  return;
	}
}

//<a onclick="disp_confirm('http://www.timestampstudios.com/')">test</a>

function disp_confirm(location)
<a onclick="disp_confirm('location')">
The location is where you will place the link to the redirect. This only has to go into the a tag and should not go into the function. That way you can use the function for multiply links.

That’s it no more is required to setup. But that’s not all if you call in the next 10 minute you get a special gift. It’s like a shamy, it’s like a towel, it’s like a sponge and it’s made in Germany and you know the German’s always make good stuff. (ok I hate that commercial and Vince); now that I got that out of the way. I’ll walk you through the function.

function disp_confirm(location) { //Calls function “disp_cofirm()” with a local variable “location

var r=confirm(" "); //Creates local variable “r” tied to a confirmation command that contains the generic message

if (r==true) { //Tests your response, if r==true (user click ok) execute task

window.open(location); } //The task: window[of the browser].open[new window](location[the URL to be defined in the anchor tag])

else { //If the user click cancel, execute secondary task

return; } } //End function and remain on the same page







Leave a Reply



blog