简体   繁体   English

使用JavaScript在iframe中重定向?

[英]Redirecting inside iframe using Javascript?

It's a cross domain iframe ( with no control on content of iframe.) 这是跨域iframe(无法控制iframe的内容。)

Here is fiddle url http://jsfiddle.net/biggenius/wH4p7/ 这是小提琴网址http://jsfiddle.net/biggenius/wH4p7/

But it is not working. 但这是行不通的。 I need to redirect user to google.com after clicking "Go" Button. 点击“转到”按钮后,我需要将用户重定向到google.com。

Thanks 谢谢

The code for your Go button need to be on that iframe then not of the other page as the other page has no control over the content like you stated yourself. 转到按钮的代码必须在该iframe上,而不是在另一页上,因为另一页无法像您自己声明的那样控制内容。 There is no way around it using iframe. 使用iframe无法解决此问题。

After if you loaded the content inside a div via ajax it would be very easy to achieve and if it's only the little search box it should work just fine. 之后,如果您通过ajax将内容加载到div中,则将很容易实现,并且如果它只是一个小的搜索框,则应该可以正常工作。

Iframes are a nightmare and in 99% of the time they can be avoided. iframe是一场噩梦,在99%的时间里,它们都是可以避免的。

You could however change the src attribute and that will make another page load inside the iframe. 不过,您可以更改src属性,这会使iframe内加载另一个页面。

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

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