English 中文(简体)
超文本——通过点击图像叫ing
原标题:HTML - calling javascript by clicking on image

I m trying to call javascript by clicking on the image but it s not working.
Please refer below for 我的法典.

Java

<script type="text/javascript">
<!--
var image1=new Image()
image1.src="images/Image_1.png"
var image2=new Image()
image2.src="images/Image_2.png"
var image3=new Image()
image3.src="images/Image_3.png"
//-->

  function login(showhide){
    if(showhide == "show"){
        document.getElementById( popupbox ).style.visibility="visible";
    }else if(showhide == "hide"){
        document.getElementById( popupbox ).style.visibility="hidden"; 
    }
  }
  </script>

我的法典

<div id="apDiv21"><img src="images/Login_OnOut.png" width="71" height="44" 
onmouseover="this.src= images/Login_OnRollover.png " 
  onmouseout="this.src= images/Login_OnOut.png " onclick="login( show );" />

  <div id="popupbox"> 
<form name="login" action="" method="post" style="background-color:#C7C7C7">
<center>Username:</center>
<center><input name="username" size="14" /></center>
<center>Password:</center>
<center><input name="password" type="password" size="14" /></center>
<center><input type="submit" name="submit" value="login" /></center>
</form>
<center><a href="login( hide );">close</a></center> 
</div> 
最佳回答

摘录本联合材料。

http://jsfiddle.net/Q5asp/

我改变了在底线上的联系,以适当掩盖它。 问题是,当你使用<条码>(显示<>条码>)时,他试图使用你的形式,因为它是同一个名字。 你必须确保你的职能名称和名称不会发生冲突。

问题回答

摘自<代码>form。 现在,它污染了名称空间,使 Java译员以<条码>login为名,指形式节而不是你的职能。 (Firefox console误差电文称,出于这一原因,“login不是一个功能”。) 否则,你可以重新命名表格,但通常不需要<条码>,即:

P.S. 您对该问题的批评是错误的。 可点击的案文的更正标记为:<a onclick=“login(藏匿);”>close</a>(但为了可使用,最好使用一个顿)。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签