Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Internet Explorer忽略javascript onblur()和focus()命令_Javascript_Jquery_Internet Explorer_Onblur_Onfocus - Fatal编程技术网

Internet Explorer忽略javascript onblur()和focus()命令

Internet Explorer忽略javascript onblur()和focus()命令,javascript,jquery,internet-explorer,onblur,onfocus,Javascript,Jquery,Internet Explorer,Onblur,Onfocus,我有以下问题。我有一个页面上有多个表单。我需要修改一些表单的默认tabindex设置。如果我使用tabindex HTML属性,那么它会破坏“工作”表单,因此我使用JQuery捕获blur()事件,并将focus()设置为正确的输入元素 我的HTML: <table> <tr> <td>Property Name: </td> <td><inp

我有以下问题。我有一个页面上有多个表单。我需要修改一些表单的默认tabindex设置。如果我使用tabindex HTML属性,那么它会破坏“工作”表单,因此我使用JQuery捕获blur()事件,并将focus()设置为正确的输入元素

我的HTML:

<table>
            <tr>
                <td>Property Name: </td>
                <td><input type="text" class="Text" id="property_name" name="property_name" /></td>
                <td width="50">&nbsp;</td>
                <td>Site Contact: </td>
                <td valign="top" rowspan="3">
                    <textarea class="Default" id="site_contact" name="site_contact"></textarea>
                </td>
            </tr>
            <tr>
                <td>Address: </td>
                <td>
                    <input type="text" class="Text" id="property_address" name="property_address" />
                </td>
            </tr>
            <tr>
                <td>City: </td>
                <td>
                    <input type="text" class="ShortText" id="property_city" name="property_city" />
                </td>
            </tr>
            <tr>
                <td>State: </td>
                <td>
                    <input type="text" class="ShortText" id="property_state" name="property_state" />
                </td>
                <td width="50">&nbsp;</td>
                <td>Comments: </td>
                <td valign="top" rowspan="3">
                    <textarea class="Default" id="property_comments" name="property_comments"></textarea>
                </td>
            </tr>
            <tr>
                <td>Zip: </td>
                <td>
                    <input type="text" class="ShortText" id="property_zip" name="property_zip" />
                </td>
            </tr>
            <tr>
                <td>Description: </td>
                <td><?php Utilities::showPropertyDescriptionDdl('property_description', 'property_description'); ?></td>
            </tr>
            <tr><td>&nbsp;</td></tr>
            <tr>
                <td>&nbsp;</td>
                <td>
                    <input type="submit" class="submit" value="Save" id="SaveProperty" /> &nbsp;
                    <input type="button" class="simplemodal-close" value="Cancel" id="CancelProperty" />
                </td>
            </tr>
        </table>
应该发生什么事: 当property\u name元素失去焦点时,property\u address元素应该获得焦点

发生的情况:当property\u name元素失去焦点时,site\u contact元素获得焦点,然后立即将焦点转发到property\u comments元素


这发生在InternetExplorer7和8中。在FireFox中,一切正常。是否有两个元素“一行”分配了onblur事件,即属性名称和站点联系人在HTML中连续出现。

我想您想禁用默认的javascript功能。它将在您的代码之后执行

试试这样的。这只是伪代码,但我认为您需要让javascript知道您不希望它执行其内置的默认事件处理程序

.blur(function() { //your code here; return false});
您应该尝试.focusout()和.focusin()。API中提到的最大区别是这些冒泡,但如果我没记错的话,它们也可以在IE6中工作+

当按下tab键时,我会使用keydown事件捕捉

$('#PropertyForm [name=property_name]').keydown( 
    function(e) { 
        if (!e.shiftKey && e.keyCode == 9) {
            $('#PropertyForm [name=property_address]').focus();
            e.preventDefault();
        }
});
$('#PropertyForm [name=property_address]').keydown( 
    function(e) { 
        if (!e.shiftKey && e.keyCode == 9) {
            $('#PropertyForm [name=property_city]').focus();
            e.preventDefault();
        }
});

6年后,我遇到了一个类似于OP的问题。我遇到了一个禁用组合框的
onblur
事件。在IE中,如果我从带有模糊事件的文本框中单击该组合框,我仍然可以展开其下拉菜单。tab键产生正确的行为
focusout()
而不是
onblur
没有改变这一点:(
$('#PropertyForm [name=property_name]').keydown( 
    function(e) { 
        if (!e.shiftKey && e.keyCode == 9) {
            $('#PropertyForm [name=property_address]').focus();
            e.preventDefault();
        }
});
$('#PropertyForm [name=property_address]').keydown( 
    function(e) { 
        if (!e.shiftKey && e.keyCode == 9) {
            $('#PropertyForm [name=property_city]').focus();
            e.preventDefault();
        }
});