简体   繁体   English

Focus()在Firebug控制台中不起作用

[英]Focus() not working in Firebug Console

I am trying to use Mozilla Firefox Firebug Console to test some code. 我正在尝试使用Mozilla Firefox Firebug控制台测试一些代码。 Below is the line I am trying to execute to focus on the link: 下面是我要执行以集中于链接的行:

document.getElementById('DEPT_TBL_DESCR$prompt').focus();

But it keeps returning this error in Firebug Console: 但它始终在Firebug控制台中返回此错误:

TypeError: document.getElementById(...) is null TypeError:document.getElementById(...)为null

Does anyone know why or how I could focus on that link/img? 有谁知道为什么或如何专注于该链接/ img?

Below is the code: 下面是代码:

<a href="javascript:pAction_win0(document.win0,'DEPT_TBL_DESCR$prompt');" tabindex="35" id="DEPT_TBL_DESCR$prompt" name="DEPT_TBL_DESCR$prompt"><img border="0" align="absmiddle" title="Look up New Department ID (Alt+5)" alt="Look up New Department ID (Alt+5)" src="/cs/hr34/cache/PT_PROMPT_LOOKUP_1.gif"></a>

This is related to this IE error message: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus. 这与以下IE错误消息有关:无法将焦点移至控件,因为它是不可见的,未启用的或者是不接受焦点的类型。

"$" is not a valid character as part of an ID or name for an HTML 4 element. 作为HTML 4元素的ID或名称的一部分,“ $”不是有效的字符。

See: What are valid values for the id attribute in HTML? 请参阅: HTML中id属性的有效值是什么?

Though it is allowed on HTML5: http://www.w3.org/html/wg/drafts/html/master/dom.html#the-id-attribute . 尽管在HTML5上允许使用: http : //www.w3.org/html/wg/drafts/html/master/dom.html#the-id-attribute

You have not sated which you are using. 您尚未确定要使用的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM