【发布时间】:2019-06-06 23:29:21
【问题描述】:
当我在test2.php 中使用document.querySelector("input[value='female']").click() 并选择值为female 的单选按钮时,它工作正常,但是当test2.php 在iframe 内时,它在test1.php 中不起作用。有什么办法可以解决这个问题吗?
test1.php
<iframe src="http://chatwithibot.com/test2.php"></iframe>
test2.php
<form action="/testx.php" method = "POST">
<input type="radio" name="gender" value="male"> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other
<input type="submit" value="Submit">
</form>
编辑:重复的解决方案链接似乎只回答有关如何从 iframe 中选择内容的问题,而不是如何更改它们。
【问题讨论】:
-
@JordanS 我读了那个,并尝试了 document.querySelectorAll('iframe').("input[value='female']").click();但它似乎不起作用。
-
你可以简单地在
<script></script>的iframe中添加radio click js代码
标签: javascript php