Javascript 函数参数不工作
我仍处于javascript的学习阶段,所以我希望有一个简单的解决方案 我有一个图像映射区域,它将在单击时运行javascript函数 以下是我所拥有的: 区域映射的相关HTML:Javascript 函数参数不工作,javascript,html,function,onclick,innerhtml,Javascript,Html,Function,Onclick,Innerhtml,我仍处于javascript的学习阶段,所以我希望有一个简单的解决方案 我有一个图像映射区域,它将在单击时运行javascript函数 以下是我所拥有的: 区域映射的相关HTML: <img id="imageMaps" src="images/20keys.jpg" usemap="#20Keys" width="100%" alt="Select Key" border="0"/> <map id="20keys" name="20keys"> <are
<img id="imageMaps" src="images/20keys.jpg" usemap="#20Keys" width="100%" alt="Select Key" border="0"/>
<map id="20keys" name="20keys">
<area shape="circle" alt="Key 1" title="Key 1" coords="42,54,32" href="#" name="key1area" onclick="keySelected(1);"/>
</map>
如果我包括一个窗口警报(“测试”)代码>@”//Alert 1“它将运行,但不会在“Alert 2”时运行,关于如何使其正常运行有何想法
如果我透露了任何可能与此有关的重要细节,请告诉我。谢谢…我没有解决的问题很简单
document.getElementByID()
很抱歉…据我所知,如果js函数位于第一页,则无法访问其中另一页中的元素,如果js函数位于另一个html页,则无法从当前页触发该函数。您同时启用了href和onClick。尚未尝试,但可能会有所帮助。@TJ,第二个页面与第一个页面位于同一html文档中href是onclick事件,但您可以将onclick嵌入到href@Placedolders_in_use,你会怎么做呢?
<div data-role="dialog" id="keyPopup" data-theme="b">
<div data-role="header">
<h1 id="keyHeader"><!--Key Description Here --></h1>
</div> <!-- /header -->
<div data-role="content">
<p><a id="summaryButton" href="#pdfReader" data-role="button" data-ajax="false" onclick="pdfSelected('summary');">Summary of Key <!--Key Number Here --></a></p>
<p><a id="manualButton" href="#pdfReader" data-role="button" data-ajax="false" onclick="pdfSelected('manual');">View Key <!--Key Number Here --> Manual</a></p>
<p><a id="interactionsButton" href="#pdfReader" data-role="button" data-ajax="false" onclick="pdfSelected('interactions');">Interaction of Key <!--Key Number Here --> with Other Keys</a></p>
</div> <!-- /content -->
<div data-role="footer">
<p class="margin">
<a href="#home" data-rel="back" data-role="button" data-inline="true" data-icon="back">Back</a>
</p>
</div> <!-- /footer -->
</div> <!-- /#keyPopup -->
var keyNumber = 0;
function keySelected(key) {
keyNumber = key;
//Alert 1
if (keyNumber === 1) {
document.getElementbyId('keyHeader').innerHTML = 'Key 1 - Description';
document.getElementbyId('summaryButton').innerHTML = 'Summary of Key 1';
document.getElementbyId('manualButton').innerHTML = 'Manual of Key 1';
document.getElementbyId('interactionsButton').innerHtml = 'Interaction of Key 1 with Other Keys';
//Alert 2
}
}