简体   繁体   中英

javascript redirect from iFrame triggered by URL

http://sequoiapacificmortgage.com/loan-application/

I have embedded the clients' loan application form (on another website) into an iFrame so the user stays on the site. The loan application (upon submit) redirects to the client's Home Page, but unfortunately, it stays within the frame rather than going to the main Home Page window. I had inquired here about how to remedy this, and was told that the Target attribute target="_top" would do the trick.

The loan application processor people have no way to add the Target attribute to the redirect URL, and they have suggested the following:

"The thank you page after the application and before the redirect URL has a unique URL.

Is it possible to code your iframe to recognize this URL and redirect the full site to your home page rather than depending on the vLender redirect within the iframe?

I am including the unique thank you page URL from Lori's website below, the ref_ID attribute is the unique application ID number assigned to my test application (the application ID's are generated using the first 3 letters of the applicant's first name [LYN for Lynsee] and the first 3 letters of the applicant's last name [TES for Testing] followed by the numeric sequence) but you should be able to remove that and have your custom site's code recognize the .php url which would trigger a redirect within your site's code that would take place before our system enacts its redirect to the home page within the iframe.

( https://www.vlender.com/apps/templates/new_thank_you.php?ref_id=LYNTES998262971 )"

Is it even possible to do this? Thanks for your advice!

regards, Ned

EDIT: You could handle the navigation of the iframe, and see what url it goes to.

use onload to see when the iframe navigated to a new page, and contentWindow.location.href to get the url from the iframe.

something like:

function checkURL() {
    if(document.getElementById('iframeID').contentWindow.location.href == "UNIQUE_URL") // if the location of the iframe is the unique url
        window.location = "redirect.html"; //redirect this page somewhere else.
});
<iframe id="iframeID" onload="checkURL();" ... //onload fires when a page loads in the iframe

on load: http://w3schools.com/jsref/event_frame_onload.asp

get iframe URL: Get current URL from IFRAME

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM