简体   繁体   English

从URL触发的iFrame进行JavaScript重定向

[英]javascript redirect from iFrame triggered by URL

http://sequoiapacificmortgage.com/loan-application/ 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. 我已经将客户的贷款申请表(在另一个网站上)嵌入到iFrame中,以便用户停留在该网站上。 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. 我在这里询问如何解决此问题,并被告知Target属性target =“ _ top”将解决问题。

The loan application processor people have no way to add the Target attribute to the redirect URL, and they have suggested the following: 贷款申请处理人员无法将Target属性添加到重定向URL,他们提出了以下建议:

"The thank you page after the application and before the redirect URL has a unique URL. “在应用程序之后且重定向URL之前的感谢页面具有唯一的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? 是否可以对iframe进行编码以识别该URL并将整个网站重定向到您的首页,而不是依赖于iframe中的vLender重定向?

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. 我在下面包括Lori网站上的唯一谢谢页面URL,ref_ID属性是分配给我的测试应用程序的唯一应用程序ID号(应用程序ID是使用申请人名字的前三个字母[LYN for Lynsee]和申请人姓氏的前3个字母[测试用的TES],后跟数字序列),但是您应该可以删除该名称,并使自定义网站的代码能够识别.php网址,从而触发您网站的代码内的重定向发生在我们的系统将其重定向到iframe中的首页之前。

( https://www.vlender.com/apps/templates/new_thank_you.php?ref_id=LYNTES998262971 )" 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. 编辑:您可以处理iframe的导航,并查看它进入的网址。

use onload to see when the iframe navigated to a new page, and contentWindow.location.href to get the url from the iframe. 使用onload查看iframe何时导航到新页面,并使用contentWindow.location.href从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 加载时: http//w3schools.com/jsref/event_frame_onload.asp

get iframe URL: Get current URL from IFRAME 获取iframe网址: 从IFRAME获取当前网址

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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