Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    js function to continue to url after confirm

    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):

    Code:
    <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:
    Code:
    <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...

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    Code:
    <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>

  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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-d.../cra/index.jsp

  • #4
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    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:

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

  • #5
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I used your code suggestion, it can be seen here:
    http://designphilanthropy.org/link-d.../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!

  • #6
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    ohhhhh I got you.

    I stole an example and modified it: ( see http://www.bennadel.com/blog/695-Ask...JavaScript.htm )

    Code:
    <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>

  • Users who have thanked DanInMa for this post:

    aladiyat23 (01-04-2012)

  • #7
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Do you know how awesome you are!!!!???

    Thank you SOOO SO MUCH!!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •