如何修改另一个网页的内容? [英] How can I modify the contents of one web page from another?
问题描述
让我解释我的问题,我有一个包含textarea的页面A。
我的页面上有一个按钮,调用一个脚本,这个脚本打开一个包含页面B的弹出窗口。
我从页面B改变页面A上的内容?
例如,检索textarea并在其中插入内容? (没有数据库)
谢谢!
pages:test.htm和popup.htm - test.htm将打开popup.htm,现在如果您在弹出窗口(textarea)中输入了某些内容并按下该按钮,文本将被发送到test.htm textarea ... :
test.htm
< h1>页面A< H1>
< form name =frm>
< textarea name =txt>< / textarea>
< button onclick =popup('popup.htm')>打开弹出窗口< / button>
< / form>
< script type =text / javascript>
function popup(url){
win = window.open(url,window1,width = 600,height = 400,status = yes,scrollbars = yes,resizable = yes);
win.focus();
}
< / script>
popup.htm:
< h1>页面B< / h1>
< form name =frm>
< textarea name =txt>< / textarea>
< button onclick =window.opener.frm.txt.value = document.frm.txt.value>更新网站A< / button>
< / form>
Let me explain my problem, I have a page "A" that contains a textarea. I have a button on my page "A" that calls a script, this script opens a pop up that contains the page "B".
How could I change something on page "A" from page "B"?
For example retrieve textarea and insert something into it? (Without database)
Thank you!
build 2 html pages: test.htm and popup.htm - the test.htm will open the popup.htm, now if you enter something in the popup (textarea) and press the button, the text will be sent to test.htm textarea...:
test.htm
<h1>Page A<h1>
<form name="frm">
<textarea name="txt"></textarea>
<button onclick="popup('popup.htm')">Open Popup</button>
</form>
<script type="text/javascript">
function popup (url) {
win = window.open(url, "window1", "width=600,height=400,status=yes,scrollbars=yes,resizable=yes");
win.focus();
}
</script>
popup.htm :
<h1>Page B</h1>
<form name="frm">
<textarea name="txt"></textarea>
<button onclick="window.opener.frm.txt.value=document.frm.txt.value">Update Site A</button>
</form>
这篇关于如何修改另一个网页的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!