禁用JavaScript:FF与IE的按钮 [英] Disabling button with javascript: FF vs IE

查看:176
本文介绍了禁用JavaScript:FF与IE的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一排按钮,它们都会创建一个我想在新选项卡中打开的pdf文件。
通过这种方式,按钮页面保持在最前端,并且打开PDF以打印。为防止点击一次按钮两次,我禁用按钮,像这样(我使用python):

 < input type ='submit 'value ='Factureren'name ='submitbutton'id ='%s'
onclick =javascript:document.getElementById('%s')。disabled = true;
document.getElementById(' S ')的className =' button_disabled';> %((but_id,)* 3)

在FF3中工作正常,即表单被提交,脚本执行,然后按钮禁用。在IE中,按钮只是禁用,但表单脚本不会执行。



有没有解决这个IE问题的方法?




  • 使用常规按钮,将其禁用,并从其处理程序中调用form.submit()。 >
  • 不要在其onclick中禁用按钮,而是保存它,并在表单的onsubmit中执行。

I have a row of buttons, which all create a pdf file which I want to open in a new tab. This way the button page stays on top, and the pdf's open to get printed. To prevent clicking a button twice I disable the button, like this (I use python):

<input type='submit' value='Factureren' name='submitbutton' id='%s'
onclick="javascript:document.getElementById('%s').disabled=true; 
document.getElementById('%s').className='button_disabled';"> % ((but_id,) *3)

In FF3 this works fine, i.e. the form is submitted, the script executed and then the button disables. In IE the button just disables, but the form script isn't executed.

Is there a solution to this IE problem?

解决方案

It is easy: a disabled submit button do not submit a form in IE. Consider to restructure your code:

  • Use a regular button, disable it, and call form.submit() from its handler.
  • Do not disable the button in its "onclick", but save it, and do it in form's onsubmit.

这篇关于禁用JavaScript:FF与IE的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆