gpt4 book ai didi

Javascript - 从未打开的页面访问元素

转载 作者:行者123 更新时间:2023-11-30 06:45:14 24 4
gpt4 key购买 nike

我的问题有点难以解释。我想做的是,我在某个页面上有一个按钮。当我按下该按钮时,我必须能够访问位于另一个页面上的表单元素(无需打开其他页面)。

按下该按钮将从该“未打开”页面编辑表单中的一些元素,然后发布它,所有这些都不会打开任何额外的弹出窗口/选项卡/窗口。表单发布后,该按钮将消失。

有问题的表单包含唯一参数,如果不访问其特定页面就无法检索这些参数,因此我无法独立模拟该表单。

我的一些猜测是使用动态 iframe 设置为“display: none”或 Ajax,但除此之外我不确定是否可行以及如何实现。

有人有什么想法吗? (对不起,如果问题不是很清楚,我尽量描述问题)

最佳答案

尝试使用框架集。下面给出的示例代码有 3 页1. 第 1 页是包含两个框架的父文档。2.frame1指的是page23.frame2引用page3

test1.htm

  <html>
<head>
<title>test</title>
<frameset rows="25px,*" frameborder="0" framespacing="0" >
<frame name="Frame2" id="Frame2" src="test2.htm"/>
<frame name="Frame1" id="Frame1" src="test3.htm"/>
</frameset>
</head>
</html>

test2.htm

   <html>
<script>
var global="testing"

</script>

</html>

test3.htm

<html>
<script>
alert(parent.window.frames[0].global);
parent.window.frames[0].global="local"

function test()
{
alert(parent.window.frames[0].global);
}

</script>

<body>
<input type="button" onclick="test()" />

</body>
</html>

在页面test2中global的值可以从页面test3.htm中改变。

关于Javascript - 从未打开的页面访问元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7536656/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com