...

View Full Version : js function to continue to url after confirm



aladiyat23
01-04-2012, 07:49 PM
I'm working on a bank website that needs disclaimers on their external links. I've searched for a tutorial or a script I could understand but need additional help if anyone is willing..

Here's my page with external links:
http://designphilanthropy.org/services/links/

Here's the js I used from the previous bank design (I don't see any code here that will do what I need):


<script language="javascript">
<!-- Hide
window.resizeTo(440, 440);

function go() {
var width = screen.width;
var height = screen.height;
if(width<650) {
width = 600;
height = 400;
} else {
width = width - 200;
height = height - 100;
}
window.resizeTo(width, height);
location.href="";
}
// end Hide -->

</script>

And here's the code on the "yes" button:

<input type="button" VALUE="YES" onclick="javascript:go();">

The link opens the disclaimer and populates the url in the browser, but I don't know how to write the js for it to continue to the destination after clicking "yes"

Any help would be greatly appreciated...

DanInMa
01-04-2012, 08:04 PM
<script type="text/javascipt">
function go() {
var answer = confirm("Do you like the color blue?")
if (answer){
alert("Bye bye!")
window.location = "http://www.google.com/";
}
else{
alert("Thanks for sticking around!")
return false
}
}
</script>

aladiyat23
01-04-2012, 08:25 PM
Thank you for the reply...
However I have to use a lengthy disclaimer message and it doesn't work so well for an alert box..

Do you know of a way for the "yes" button to continue to the url that is already populated in the link-disclaimer.html browser bar?

example of 1 of the links:
http://designphilanthropy.org/link-disclosure.html?url=https://www.annualcreditreport.com/cra/index.jsp

DanInMa
01-04-2012, 08:28 PM
ok so you have a screen with 2 buttons, the no buttong does what you want, the yes button should go to another page correct?

if so:


<script type="text/javascipt">
function go() {
window.location = "http://www.google.com/";
}
</script>

aladiyat23
01-04-2012, 08:39 PM
I used your code suggestion, it can be seen here:
http://designphilanthropy.org/link-disclosure.html?url=https://www.annualcreditreport.com/cra/index.jsp

Since all my external links are different I removed the url from your js and left the quotes. The correct url still populates in the browser bar but I can't figure out how to get it to continue on after confirm..

Thank you for your suggestions!

DanInMa
01-04-2012, 08:42 PM
ohhhhh I got you.

I stole an example and modified it: ( see http://www.bennadel.com/blog/695-Ask-Ben-Getting-Query-String-Values-In-JavaScript.htm )



<html>
<head>
<title>Link Disclosure</title>

<style>
td {
background-color: #f2f2f2;
color:#333333;
font-family:Arial, Helvetica, sans-serif;
font-size: 12px;
line-height:16px
}
</style>
</head>

<body>
<table align="center" width="50%" bgcolor="#e5e5e5" border="0" cellspacing="0" cellpadding="20" style="border:1px; border-color:#666666; border-style:dashed;border-width:1px;">
<tr>
<td><strong>You are accessing a third party website link or document.</strong>
<br />
<br />
By clicking "YES" below you acknowledge that you are accessing a website or document not under the control of First Avenue National Bank. If you do not wish to access the website or document please click "NO" and you will be returned to the previous page.</td>
</tr>
<tr>
<td align="center">
<script type="text/javascript">

// Build an empty URL structure in which we will store
// the individual query values by key.
var objURL = new Object();


// Use the String::replace method to iterate over each
// name-value pair in the query string. Location.search
// gives us the query string (if it exists).
window.location.search.replace(
new RegExp( "([^?=&]+)(=([^&]*))?", "g" ),

// For each matched query string pair, add that
// pair to the URL struct using the pre-equals
// value as the key.
function( $0, $1, $2, $3 ){
objURL[ $1 ] = $3;
}
);

</script>
<form>
<input type="button" VALUE="YES" onclick="javascript:go();">&nbsp;&nbsp;
<input type="button" VALUE="NO" onclick="javascript:window.close();">
</form></td>
</tr>
<tr>
<td>First Avenue National Bank is happy to make available to you links to other sites on the World Wide Web. First Avenue National Bank believes the links contained on their pages are to reputable companies. Nevertheless, First Avenue National Bank makes no representations or warranties regarding non-First Avenue National Bank sites or the companies maintaining them. First Avenue National Bank does not control or monitor such websites and First Avenue National Bank does not endorse the content or the use of such websites. If you choose to access non-First Avenue National Bank websites through links on our pages you accept responsibilities for all related risks.</td>
</tr>
</table>
<script type="text/javascript">
function go(){
if (typeof objURL[ "url" ]!= 'undefined'){
window.location = objURL[ "url" ];
}
else{
alert("url not found")
}

}
</script>
</body>
</html>

aladiyat23
01-04-2012, 09:04 PM
Do you know how awesome you are!!!!???

Thank you SOOO SO MUCH!!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum