jQuery.专注在ie11中不起作用
jQuery.focus not working in I.E 11
我想从URL
中得到focus
上的anchor tag
锚标记
<a id='714895'> </a>
http://test.com/sites/alzheimers-disease-early-detection.aspx?ShowAllComments=True # 714895
jQuery代码
try
{
if(document.URL.indexOf("?ShowAllComments=True#") >= 0){
var elementClicked = "#" +location.href.split('#')[1];
$("elementClicked").focus();
}
catch(e)
{alert(e.message);}
Also tried
try
{
if(document.URL.indexOf("?ShowAllComments=True#") >= 0){
var elementClicked = "#" +location.href.split('#')[1];
$("elementClicked").focus().focus();
}
catch(e)
{alert(e.message);}
和
try
{
if(document.URL.indexOf("?ShowAllComments=True#") >= 0){
setTimeout(function(){
var elementClicked = "#" +location.href.split('#')[1];
$("elementClicked").focus();},100);
}
}
catch(e)
{alert(e.message);}
代码在Firefox
和Chrome
上工作完美,但在I.E
上不工作。任何其他的方式或修改应该做的工作在i.e. .
尝试:
window.setTimeout(function(){
var elementClicked = "#"+location.href.split('#')[1];
$('#elementClicked').focus(); }, 100);
IE 11时间对其他控件进行聚焦,然后窃取焦点并将其添加到elementClicked。
否则试试这个
try {
function elementFocus(e){
if(document.URL.indexOf("?ShowAllComments=True#") >= 0){
var elementClicked = "#" +location.href.split('#')[1];
$("elementClicked").focus();
e.preventDefault();
}
}
catch(e){alert(e.message);}
相关文章:
- addEventListener在IE11中不起作用
- 悬停时颜色变为灰度在IE11中不起作用
- RadTreeView在IE11不必要的触发事件中不起作用
- javascript对象检查在IE11中不起作用
- 禁用编辑和删除按钮在IE9中不起作用,但在IE11中起作用
- HTML 中的锚标记在 IE11 中单击时不起作用
- CSS 缩放在 IE11 中不起作用
- IE11 脚本加载不起作用(有时)
- swfObject 嵌入对象在 ie11 中不起作用
- navigator.msSaveBlob 函数在 IE11 中不起作用
- window.getSelection不起作用在IE11中不起作用
- win.document 在 IE11 中不起作用
- 切换 JavaScript 代码在 IE11 中不起作用
- window.open() 在 IE11 中不起作用
- 为什么 forEach() 在 IE11 的 iframe 中不起作用
- 脚本延迟在 IE11 上不起作用
- AES-KW的解包键功能在IE11中不起作用
- HTML5拖放在IE11上不起作用
- jQuery.专注在ie11中不起作用
- AngularJs的List属性在ie11中不起作用