不确定如何标记OnClick事件

时间:2015-03-09 15:53:44

标签: javascript html onclick robot

我有一个html文档,其中有一个表单,选择按钮可以激活运行机械臂的程序,但是,我还需要将此按钮链接到另一个页面。基于我之前所做的研究,我认为OnClick事件将完全符合我的需要。我的问题是我不太确定如何引用机器人命令和指向另一个页面的链接。

<td style="width: 120px; height: 47px"><form action="../../Karel/RIGHT1" method="GET">
                    <div align="left">
                      <input type="hidden" name="object" value="numreg">
                      <input type="hidden" name="operate" value="setint">
                      <input type="hidden" name="index" value="1">
                      <input type="hidden" name="value" value="0">                                                   
                      <input type="image" src="onegrey.jpg" name="submit" border="0"  width="137">
                      <a href="rightmanual.stm" onclick=""
                      <a href="left.stm" target="_blank"><img src="leftnotavailable.jpg" border="0" alt="rightmanual.stm"/></div>
                  </form>

..//../Karel/RIGHT1是文档试图调用的机器人程序,rightmanual.stm是我选择图像/按钮onegrey.jpg时需要链接的页面。我试图尽可能具体,感谢我发送的任何帮助。

1 个答案:

答案 0 :(得分:0)

所以你想重定向到表单提交的另一个页面?如果是这种情况,请在输入中添加一个id标记,例如名称。 &#34; btnRedirect&#34;

<input id="btnRedirect" type="image" src="onegrey.jpg" name="submit" border="0"  width="137">

然后,您可以使用jQuery进行onclick事件。更多关于jQuery的信息。

<head>
<script>
$.('#btnRedirect').click(function() {
window.location.href = "http://www.url.com";
})
</script>
<head>

或者您只需将onClick事件添加到提交按钮

即可
<input type="image" src="onegrey.jpg" name="submit" onClick="location.href='index.html'" border="0"  width="137">