不确定如何标记 OnClick 事件

问题描述 投票:0回答:1

我有一个 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 时我还需要链接到的页面。我尝试尽可能具体,感谢您提供的任何帮助。

javascript html onclick
1个回答
0
投票

您想在表单提交时重定向到另一个页面吗?如果是这种情况,请在输入中添加一个 id 标签,并带有名称,例如。 “btnRedirect”。

<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">
© www.soinside.com 2019 - 2024. All rights reserved.