如何使用javascript传递值到iFrame? [英] How can I pass value to iFrame with javascript?
本文介绍了如何使用javascript传递值到iFrame?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的页面和onClick事件中打开一个iFrame尝试向iframe的文本框发送一个值
I opened an iFrame in my page and onClick event try to send a value to the textbox of the iframe
这是我的javascript代码
This is my javascript code
<script type="text/javascript">
function TextToFrame()
{
var frame = frames['frame1'];
frame.document.getElementById("u").value = "wallace";
}
</script>
IFrame加载页面,但是当我单击按钮时,它不发送任何值。
它刷新主页和iFrame
IFrame loads the page but when I click the Button , it doesn't send any value. It refreshes the main page and iFrame
<asp:Button ID="Button1" runat="server" OnClientClick="TextToFrame();" Text="Send Value" />
<IFRAME id="frame1" name="frame1" src="http://tweakers.net/my.tnet/login?location=http%3A%2F%2Ftweakers.net%2F" width=500px height=500px runat="server">
我做错了什么?
任何帮助感谢
What am I doing wrong? any help appreciated
推荐答案
我不认为你可以修改来自不同域的iframe中的HTML。您可以将iframe来源更改为以下内容:
I don't think you can modify the HTML in an iframe from a different domain. You might be able to change the iframe source to something like:
http://tweakers.net/my.tnet/login?u=wallace
但网站应该给你这样的选项。
but the site should give you an option like that.
这篇关于如何使用javascript传递值到iFrame?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文