English 中文(简体)
在iframe子节点中调用Javascript函数
原标题:Calling Javascript function in child iframe node

如何调用子级<;中存在的javaScript函数;iframe>父节点?我正在使用jquery选择器来选择正确的iframe节点,但不知道如何调用该函数。此外,还使用jquery动态添加了所需的iframe。

例如,iframe是

<iframe id="frameOne" src="http://form_one.html"><iframe>

我需要做这样的事

$(#frameOne).submitList();

其中submitList()是form_one.html中的一个函数。

谢谢

问题回答
document.getElementById( frameOne ).contentWindow.submitList();

frameOne应该是框架的ID!

只要这两个URL都在同一个域中,它就应该工作。

如果不是,则会遇到跨域问题





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.