非常感谢克里斯托珀!也许我不够精确,我无法做到。这就是现在运行良好的方法:
<center><h3 class="auto-style21">Camera Control
<input type="checkbox" id="myCheck" onclick="myFunction()" checked="checked"> AutoStop aktiviert: <i id="demo"></i></h3>
<script>
function myFunction() {
var x = document.getElementById("myCheck").checked;
document.getElementById("demo").innerHTML = x;
}
</script>
但现在,我想发送 x 值而不是发送 auto=true 或 false,请参见下文:
<map name="image-map">
<img src="ptz.jpg" usemap="#image-map">
<area alt="Up" title="Up" target="control" coords="127,31,25" shape="circ"
href="control.php?cmd=0&auto=false">
<area alt="Down" title="Down" target="control" coords="127,170,30" shape="circ"
href="control.php?cmd=2&auto=false">
<area alt="Left" title="Left" target="control" coords="39,93,30" shape="circ"
href="control.php?cmd=4&auto=false">
<area alt="Right" title="Right" target="control" coords="217,93,25" shape="circ"
href="control.php?cmd=6&auto=false">
<area alt="UpRight" title="UpRight" target="control" coords="181,49,22"
shape="circ" href="control.php?cmd=91&auto=true">
<area alt="UpLeft" title="UpLeft" target="control" coords="71,49,22"
shape="circ" href="control.php?cmd=90&auto=true">
<area alt="DownLeft" title="DownLeft" target="control" coords="63,144,22"
shape="circ" href="control.php?cmd=92&auto=true">
<area alt="DownRight" title="DownRight" target="control" coords="188,144,22"
shape="circ" href="control.php?cmd=93&auto=true">
<area alt="Stop" title="Stop" target="control" coords="126,95,46" shape="circ"
href="control.php?cmd=1&auto=true">
</map>
</center>
我尝试了 document.write,但同样,我对疯狂的语法太愚蠢了。
document.getElementById --> InnerHTML 工作正常,这是现在的解决方案,以防万一有人好奇:
<script>
function myFunction() {
var x = document.getElementById("myCheck").checked;
document.getElementById("demo").innerHTML = x;
var up = "<area alt=\"Up\" title=\"Up\" target=\"control\"
coords=\"127,31,25\" shape=\"circ\" href=\"control.php?cmd=0&auto=";
var down = "<area alt=\"Down\" title=\"Down\" target=\"control\"
coords=\"127,170,30\" shape=\"circ\" href=\"control.php?cmd=2&auto=";
var left = "<area alt=\"Left\" title=\"Left\" target=\"control\"
coords=\"39,93,30\" shape=\"circ\" href=\"control.php?cmd=4&auto=";
var right= "<area alt=\"Right\" title=\"Right\" target=\"control\"
coords=\"217,93,25\" shape=\"circ\" href=\"control.php?cmd=6&auto=";
var upright = "<area alt=\"UpRight\" title=\"UpRight\" target=\"control\"
coords=\"181,49,22\" shape=\"circ\" href=\"control.php?cmd=91&auto=";
var upleft = "<area alt=\"UpLeft\" title=\"UpLeft\" target=\"control\"
coords=\"71,49,22\" shape=\"circ\" href=\"control.php?cmd=90&auto=";
var downleft = "<area alt=\"DownLeft\" title=\"DownLeft\" target=\"control\"
coords=\"63,144,22\" shape=\"circ\" href=\"control.php?cmd=92&auto=";
var downright= "<area alt=\"DownRight\" title=\"DownRight\"
target=\"control\" coords=\"188,144,22\" shape=\"circ\" href=\"control.php?
cmd=93&auto=";
var autostop = x + "\">";
document.getElementById("camup").innerHTML = up + autostop;
document.getElementById("camdown").innerHTML = down + autostop;
document.getElementById("camleft").innerHTML = left + autostop;
document.getElementById("camright").innerHTML = right + autostop;
document.getElementById("camupright").innerHTML = upright + autostop;
document.getElementById("camupleft").innerHTML = upleft + autostop;
document.getElementById("camdownleft").innerHTML = downleft + autostop;
document.getElementById("camdownright").innerHTML = downright + autostop;
}
</script>
<map name="image-map">
<img src="ptz.jpg" usemap="#image-map">
<p id="camup"></p>
<p id="camdown"></p>
<p id="camleft"></p>
<p id="camright"></p>
<p id="camupright"></p>
<p id="camupleft"></p>
<p id="camdownleft"></p>
<p id="camdownright"></p>
<!--
<area alt="Up" title="Up" target="control" coords="127,31,25" shape="circ"
href="control.php?cmd=0&auto=false">
<area alt="Down" title="Down" target="control" coords="127,170,30"
shape="circ" href="control.php?cmd=2&auto=false">
<area alt="Left" title="Left" target="control" coords="39,93,30" shape="circ"
href="control.php?cmd=4&auto=false">
<area alt="Right" title="Right" target="control" coords="217,93,25"
shape="circ" href="control.php?cmd=6&auto=false">
<area alt="UpRight" title="UpRight" target="control" coords="181,49,22"
shape="circ" href="control.php?cmd=91&auto=true">
<area alt="UpLeft" title="UpLeft" target="control" coords="71,49,22"
shape="circ" href="control.php?cmd=90&auto=true">
<area alt="DownLeft" title="DownLeft" target="control" coords="63,144,22"
shape="circ" href="control.php?cmd=92&auto=true">
<area alt="DownRight" title="DownRight" target="control" coords="188,144,22"
shape="circ" href="control.php?cmd=93&auto=true">
-->
<area alt="Stop" title="Stop" target="control" coords="126,95,46"
shape="circ" href="control.php?cmd=1&auto=true">
</map>
</center>
<iframe name="control" style="display:none"></iframe>
不要忘记在身体负荷上调用 myFunction。
再次感谢,干杯,Falk