Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Iframe不使用表单中的标签_Javascript_Html_Iframe - Fatal编程技术网

Javascript Iframe不使用表单中的标签

Javascript Iframe不使用表单中的标签,javascript,html,iframe,Javascript,Html,Iframe,问题 我想在单击iframe时选中一个复选框。通常我只会在输入周围使用标签。这适用于图像、文本和其他内容。但它似乎对iframes不起作用 这是我的代码 <form> <label> <iframe src="http://yx-ads6.com/banner_show.php?section=General&amp;pub=836169&amp;format=468x60&amp;ga=g" frameborder="0

问题

我想在单击iframe时选中一个复选框。通常我只会在输入周围使用标签。这适用于图像、文本和其他内容。但它似乎对iframes不起作用

这是我的代码

<form>
  <label>

      <iframe src="http://yx-ads6.com/banner_show.php?section=General&amp;pub=836169&amp;format=468x60&amp;ga=g" frameborder="0" scrolling="no" width="468" height="60" marginwidth="0" marginheight="0"></iframe

    <input type="checkbox">
  </label>
</form>


基本上,单击事件在
iframe
中,而不是在标签中,因此不检查输入


你可以用JS来做这件事。看看这个答案:

基本上,点击事件在
iframe
中,而不是标签中,因此输入没有被检查


你可以用JS来做这件事。看看这个答案:

我会在iframe上面使用一个元素,如下所示:

HTML

<form>
  <label>
    <span></span>
      <iframe frameborder="0" scrolling="no" width="468" height="60" marginwidth="0" marginheight="0" style="background-color: #fff"></iframe>
    <input type="checkbox">
  </label>
</form>

下面是一个关于这段代码的示例。

我将使用iframe上面的一个元素,如下所示:

HTML

<form>
  <label>
    <span></span>
      <iframe frameborder="0" scrolling="no" width="468" height="60" marginwidth="0" marginheight="0" style="background-color: #fff"></iframe>
    <input type="checkbox">
  </label>
</form>

这是一个关于这段代码的例子。

我不擅长JavaScript,但我如何让它在脚本检测到点击后选中复选框?我不擅长JavaScript,但我如何让它在脚本检测到点击后选中复选框?我更喜欢在顶部使用一个span,使这项工作与我在previus中所做的一样,其中一个未更新,如果修复了链接,则效果良好:)我更希望在顶部使用一个跨度,使此工作与我在previus中所做的一样。如果修复了链接,则效果良好:)