页面加载时焦点过滤选择
为什么下面的代码没有聚焦过滤选择?
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://yandex.st/dojo/1.6.0/dojo/dojo.xd.js" djConfig="parseOnLoad: true"></script>
<style type="text/css">
@import "http://yandex.st/dojo/1.6.0/dijit/themes/claro/claro.css";
</style>
<script type="text/javascript">
<!--
dojo.require("dijit.form.FilteringSelect");
dojo.addOnLoad(function(){
dijit.byId('dept').focus();
});
-->
</script>
</head>
<body class="claro">
<select name="dept" id="dept" dojoType="dijit.form.FilteringSelect" >
<option value=""></option>
<option value="test">test</option>
<option value="test1">test1</option>
</select>
</body>
</html>
我用 ie7 和 firefox 3/4 尝试过 - 它有效。
但在 ie8 中失败:-(
这可能是道场错误 - 还是我做错了什么?
dojo.addOnLoad() 什么时候触发?在 DOM 准备好之后,或者在所有小部件都正确初始化之后?
问候
格哈德
why does the following code don't focus the filteringselect?
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://yandex.st/dojo/1.6.0/dojo/dojo.xd.js" djConfig="parseOnLoad: true"></script>
<style type="text/css">
@import "http://yandex.st/dojo/1.6.0/dijit/themes/claro/claro.css";
</style>
<script type="text/javascript">
<!--
dojo.require("dijit.form.FilteringSelect");
dojo.addOnLoad(function(){
dijit.byId('dept').focus();
});
-->
</script>
</head>
<body class="claro">
<select name="dept" id="dept" dojoType="dijit.form.FilteringSelect" >
<option value=""></option>
<option value="test">test</option>
<option value="test1">test1</option>
</select>
</body>
</html>
I tried it with ie7 and firefox 3/4 - it works.
but it fails in ie8 :-(
may this be a dojo bug - or am I doing something wrong?
when does dojo.addOnLoad() fire? after the DOM is ready, or after all widgets have properly been initalized?
regards
gerhard
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是非常有趣的错误..我做了一些小研究并找到了解决方案。也许它看起来像一个“肮脏的黑客”,但它仍然可以帮助你。
您可以简单地添加超时:
用户不会注意到,但它可以给 IE 喘息的时间。
这对我来说在 IE8 中工作
it's very intresting bug.. i have made small research and found solution. maybe it looks like a "dirty hack", but still it can help you.
you can simply add timeout:
Not noticeable by a user but it gives IE a moment to breathe.
It's work in IE8 for me
我不确定哪些浏览器完全支持这一点,但您可以尝试:
另外,如果您可以只使用链接标记,我不明白为什么您要使用
Import
语句:之前:
之后:
I'm not sure what browsers fully support this, but you could try:
Also, I don't see why you're using an
Import
statement if you could just use the link tag:Before:
After: