辅助功能,当在我的图像上按 Enter 时,屏幕会重新加载

发布于 2025-01-09 06:09:13 字数 2572 浏览 7 评论 0原文

我正在尝试转换我的 JS 代码,以便我可以通过 Tab 键浏览它并按 Enter 键来显示时间打孔。然而,在我将其转换为按钮后,它不再按照预期的方式运行。每当我在图像上按 Enter 时,它都会重新加载整个页面。我在这里做错了什么?

原始代码

<img tal:condition="python:len(punches)>0" onclick="toggleVisibilityByRow('Swipe_line')" 
ref="javascript:void(0);" src="/AcuStaf/images/fold.gif" id="img_Swipe_line" class="clickable" />
&nbsp;
<span tal:condition="float_swipes" id="swipe_float_units" style="display:none">
<span style="font-weight:bold">Float&nbsp;to&nbsp;</span>
<span tal:replace="structure python:container.util.getUnitSelects(my_form='swipe_form', my_var='float_unit', my_var_value='', unit_type='sch_unit', multiunit=False, use_unit_default=False, text_input=True)"></span>
<input type="button" data-inline="true" data-mini="true" onclick="jQuery('#float_unit').attr('disabled','disabled'); jQuery('#swipe_float_units').hide(); jQuery('#float_swipes_button').show()" style="margin-left:3em" title="Float to a alternate location or work" value="Remove Float" />
<br/>
<span style="font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
</span>

转换为可访问性按钮

<button class="blend" onclick="toggleVisibilityByRow('Swipe_line')" 
                  title="Show time punches">
                  <img src="/AcuStaf/images/fold.svg" 
                  id="img_Swipe_line" class="clickable" alt=">" tal:condition="python:len(punches)>0" ref="javascript:void(0);">
                  </button>
&nbsp;
<span tal:condition="float_swipes" id="swipe_float_units" style="display:none">
<span style="font-weight:bold">Float&nbsp;to&nbsp;</span>
<span tal:replace="structure python:container.util.getUnitSelects(my_form='swipe_form', my_var='float_unit', my_var_value='', unit_type='sch_unit', multiunit=False, use_unit_default=False, text_input=True)"></span>
<input type="button" data-inline="true" data-mini="true" onclick="jQuery('#float_unit').attr('disabled','disabled'); jQuery('#swipe_float_units').hide(); jQuery('#float_swipes_button').show()" style="margin-left:3em" title="Float to a alternate location or work" value="Remove Float" />
<br/>
<span style="font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
</span>

我在“nbsp;”之后没有更改任何内容只是提供它以备不时之需。

I'm trying to convert my JS code in order for me to tab through it and press Enter to show time punches. However after I converted it into a button it stops behaving the way it was suppose to. Whenever I press Enter on the image it reloads the whole page. What did I do wrong here?

Original code

<img tal:condition="python:len(punches)>0" onclick="toggleVisibilityByRow('Swipe_line')" 
ref="javascript:void(0);" src="/AcuStaf/images/fold.gif" id="img_Swipe_line" class="clickable" />
 
<span tal:condition="float_swipes" id="swipe_float_units" style="display:none">
<span style="font-weight:bold">Float to </span>
<span tal:replace="structure python:container.util.getUnitSelects(my_form='swipe_form', my_var='float_unit', my_var_value='', unit_type='sch_unit', multiunit=False, use_unit_default=False, text_input=True)"></span>
<input type="button" data-inline="true" data-mini="true" onclick="jQuery('#float_unit').attr('disabled','disabled'); jQuery('#swipe_float_units').hide(); jQuery('#float_swipes_button').show()" style="margin-left:3em" title="Float to a alternate location or work" value="Remove Float" />
<br/>
<span style="font-weight:bold">            </span>
</span>

Converting to button for accessibility

<button class="blend" onclick="toggleVisibilityByRow('Swipe_line')" 
                  title="Show time punches">
                  <img src="/AcuStaf/images/fold.svg" 
                  id="img_Swipe_line" class="clickable" alt=">" tal:condition="python:len(punches)>0" ref="javascript:void(0);">
                  </button>
 
<span tal:condition="float_swipes" id="swipe_float_units" style="display:none">
<span style="font-weight:bold">Float to </span>
<span tal:replace="structure python:container.util.getUnitSelects(my_form='swipe_form', my_var='float_unit', my_var_value='', unit_type='sch_unit', multiunit=False, use_unit_default=False, text_input=True)"></span>
<input type="button" data-inline="true" data-mini="true" onclick="jQuery('#float_unit').attr('disabled','disabled'); jQuery('#swipe_float_units').hide(); jQuery('#float_swipes_button').show()" style="margin-left:3em" title="Float to a alternate location or work" value="Remove Float" />
<br/>
<span style="font-weight:bold">            </span>
</span>

I did not change anything after "nbsp;" just providing it in case it matters.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文