使用条形码阅读器防止chrome中的打开下载窗口 [英] Prevent open downloads window in chrome with barcode reader

查看:74
本文介绍了使用条形码阅读器防止chrome中的打开下载窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站(MVC3,C#)和条形码阅读器存在此问题。
在我的表格中我有这样的内容:

 < ajax form ....> 

< input type = text />

< div id = list>
< / div>

< / form>

输入用条形码阅读器填充并自动提交带有ajax的表单,填写div使用id = list。
我的问题是,使用chrome和ie,在文本被提交后,下载窗口出现在chrome中,收藏夹窗口出现在ie中。我想这是因为条形码阅读器在文本中加入[CR] [LF]并打开那些窗口。我认为条形码阅读器在某个时刻插入了一个ctrl-j,因为该组合打开了chrome中的下载窗口和ie中的收藏夹,但是使用firefox下载窗口没有打开(也是ctrl-j)。



我不想告诉我的客户配置条形码阅读器以便我的页面正常工作,所以我想在javascript中使用sollution来解决这个问题。



谢谢!!!

解决方案

我找到了这个链接,但唯一的解决方案是更改扫描仪的默认字符...我不确定我可以改变我的虽然如此,像你一样,我也在寻找与浏览器相关的修复工具......也许是javascript。我将尝试使用javascript处理字符以防止发生这种情况...如果我有任何成功,我会尝试并记得回到这里并告诉你hehehehehe



我认为这解决了这个问题......

  $(文件).ready(function(){
$(#input)。keydown(function(e){
if(e.which == 17 || e.which == 74){
e.preventDefault();
} else {
console.log(e.which);
}
})
});

lemme知道他的作品是否也适合你...确保你也清空了缓存...... / p>

i have this problem with my website (MVC3, C#) and a barcode reader. In my form i have something like this:

<ajax form....>

<input type=text />

<div id=list>
</div>

</form>

And the input is filled with a barcode reader and automatically submits the form that with ajax, fills the div with the id = list. My problem is that with chrome and ie, after the text is submited, a downloads windows appears in chrome and the favorites window appears in ie. I suppose that is because the barcode reader insers a [CR][LF] in the text and that opens those windows. I thought that the barcode reader was inserting a ctrl-j in some moment because that combination opens the downloads window in chrome and the favorites in ie, but with firefox the downloads window doesnt open (and is also ctrl-j).

I dont want to tell my client to configure the barcode reader so my page works, so i want a sollution in javascript maybe that fixes that problem.

thanks!!!

解决方案

i found this link but the only solution was to change your scanner's default character... i'm not sure I can change mine though so , like you, I'd be looking for a browser-related fix too.. maybe javascript. i'll try handling the characters with javascript to prevent that from happening... if I have any success i'll try and remember to come back here and tell you hehehehehe

i think this solves the issue....

$(document).ready(function(){
    $("#input").keydown(function(e){
        if(e.which==17 || e.which==74){
            e.preventDefault();
        }else{
            console.log(e.which);
        }
    })
});

lemme know whether his works for you too.. make sure you empty the cache too...

这篇关于使用条形码阅读器防止chrome中的打开下载窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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