访问动态创建的iframe内容/元素,如文本框,来自javascript的标签 [英] accessing dynamically created iframe contents/elements like textbox, label from javascript

查看:120
本文介绍了访问动态创建的iframe内容/元素,如文本框,来自javascript的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在动态创建一个iframe然后调用aspx页面,我需要做的是访问iframe页面的元素并更改它(只有特定元素,如文本框或标签等)值而不重新加载整个页面。



第一个任务是访问被调用到我的iframe的页面元素,我试图用javascript访问它们但到目前为止没有进展。



i尝试过各种各样的解决方案:



如何在Javascript中获取iframe的正文内容? [ ^ ]

i am dynamically creating an iframe then calling aspx pages into it, what i need to do is access the elements of the iframe page and change its ( only specific element like text box or label etc.) value without reloading the whole page.

the first task is to access the elements of pages being called into my iframe, i am trying to acess them with javascript but no progress so far.

i have tried various solution like this :

How to get the body's content of an iframe in Javascript?[^]

推荐答案

您可以在iframe中显示的页面中放置一个JS函数然后从父母那里调用该函数。



You can put a JS function in the page that shows up in the iframe and then call that function from the parent.


#iframe1)[< span class =code-digit> 0 ]。contentWindow.functionInPage();
("#iframe1")[0].contentWindow.functionInPage();





然后在该页面您可以轻松访问所有控件。



and then in that page you have easy access to all the controls.


这篇关于访问动态创建的iframe内容/元素,如文本框,来自javascript的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆