简体   繁体   English

通过Java重定向按钮

[英]Redirect button via Javascript

I have a contact form inserted into my website via an iframe. 我已经通过iframe将联系表单插入到我的网站中。 I am unable to modify the contact form but I can insert some javascript within the iframe itself. 我无法修改联系表单,但可以在iframe本身中插入一些JavaScript。 I would like to have the contact form redirect the user to a new page upon successfully submitting the form. 我希望联系表单在成功提交表单后将用户重定向到新页面。 That new page should load in the parent page and not the iframe. 该新页面应在父页面而不是iframe中加载。 Any ideas how I could accomplish this? 有什么主意我可以做到吗? This is the page i'm trying to modify http://www.oneupland.com/contact 这是我正在尝试修改的页面http://www.oneupland.com/contact

After a successful submission try executing either of the below 成功提交后,请尝试执行以下任一操作

window.location.href="https://stackoverflow.com"
or 要么
window.location.replace("http://stackoverflow.com");

Not really sure if u can access it but u can try something like this.. 不太确定您是否可以访问它,但是您可以尝试这样的操作。

// keep a reference to the window element of the iframe :
   var winIFrame = window.frames["myFrame"].contentWindow;

// with this you can access any DOM element in the iframe
   winIFrame.document.getElementById("myForm").onsubmit = function() { 
     window.location.replace("http://your_redirect.com");
     return false;
   }

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

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