我有一些现有的JavaScript代码,我无法更改,加载到iframe中。 iframe中的初始页面是本地页面,但JavaScript中的链接(实际上是<input type="button"...>
)转到外部内容。我正在寻找一种方法来更改iframe所在的主页面,当点击iframe中的按钮转到外部URL时。
我可以以某种方式访问iframe中的本地页面css类吗?如果失败了,可以使用.unload()代替.click吗?我只是设法使用.unload来捕获父框架中的页面更改。
<iframe name="venueFrame" id="venueFrame" frameBorder="0" src=""><p>Your browser does not support iframes.</p></iframe>
<script>
function selectVenue(page){
compleateURL='venuemaps/'+page;
document.getElementById('venueShadow').style.display="block";
$("#venueFrame").attr({src:compleateURL});
}
</script>
答案 0 :(得分:0)
很难知道没有看到任何代码,但您可以通过执行
绑定到iframe上的点击$('#iframe').bind('click', function(e) {
//Stuff to do
});
只要点击iframe中的任何内容,就会发生这种情况。如果您尝试根据链接更改某些特定内容,那么您将很难做到这一点。