简体   繁体   中英

How can I keep the focus to my selected text when I click a button?

I have a text selection for my editor in IE written in javascript.

checkedText = parent.frames['myframe'].document.selection.createRange();

Everything works ok just the first time. Then if I click a button the focus is gone for a while and the checkedText has the previous text as well. I tried also keep the focus with:

checkedText.select();

but it doesn't work. I know it is a but hard to explain my problem but if anyone has an idea I would appreciate it.

thanks a lot

document.getElementById("test").select();
document.getElementById("test").focus();

Does the following not work? If not, maybe you can post a page showing the problem.

parent.frames['myframe'].focus();
checkedText.select();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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