能使用javascript做一个confirm,默认焦点落在"取消"上吗?

yellowzhong 2003-07-17 10:09:27
我知道vbscript可以做,但我想用javascript做,
我尝试过使用showModelDialog,但打开的"网页对话框"无法使用focus()方法"

哪位会做?
...全文
306 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
flying_sunny 2003-07-21
  • 打赏
  • 举报
回复
zhanghk(lion)方法是用button 的focus方法
focus说明:
Causes a control to receive the focus, and executes the code specified by the onfocus event.

Syntax

object.focus()

Remarks

This method fires the onfocus event.

As of Microsoft® Internet Explorer 5, elements that expose the focus method must have the TABINDEX attribute set.


另getElementById是document的方法
Returns a reference to the first object with the specified value of the ID attribute.

Syntax

oElement = document.getElementById(sIDValue)
Parameters

sIDValue Required. String that specifies the value of an ID attribute.


Return Value

Returns the first object with the same ID attribute as the specified value.

Remarks

If the ID value belongs to a collection, the getElementById method returns the first object in the collection.








yellowzhong 2003-07-21
  • 打赏
  • 举报
回复
但是zhanghk的方法难道不需要新开一个窗口吗?
形印声传 2003-07-20
  • 打赏
  • 举报
回复
zhanghk的方法不是用showmodeldialog的。
yellowzhong 2003-07-19
  • 打赏
  • 举报
回复
问zhanghk(lion):
showModelDialog打开的页面里不是把focus()方法屏蔽掉了吗,怎么还可以用呢?
zhanghk 2003-07-18
  • 打赏
  • 举报
回复
<script>
function OnLoad()
{
document.getElementById("Cancel").focus();
}
</script>
<body onload="OnLoad()">
<input type="button" name="OK" id="OK" value="确定">
<input type="button" name="Cancel" id="Cancel" value="取消">
</body>
saintKnight 2003-07-18
  • 打赏
  • 举报
回复
showModelDialog方法会自动获得焦点的吧
cheqiang 2003-07-17
  • 打赏
  • 举报
回复
关注!顺便帮你顶一下!
yellowzhong 2003-07-17
  • 打赏
  • 举报
回复
??
没回音?

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧