最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

codemirror search simulate CTRL+F keys with javascript - Stack Overflow

programmeradmin4浏览0评论

I'm trying to open the codemirror search dialog (normally activated by pressing CTRL+F)
by pressing a button:

I tried to use

window.find()

but it does not open the dialog, it only highlights the text in the editor...

DEMO

I'm trying to open the codemirror search dialog (normally activated by pressing CTRL+F)
by pressing a button:

I tried to use

window.find()

but it does not open the dialog, it only highlights the text in the editor...

DEMO

Share Improve this question edited Jun 2, 2015 at 9:30 jezrael 864k102 gold badges1.4k silver badges1.3k bronze badges asked Jan 1, 2015 at 22:38 neoDevneoDev 3,0393 gold badges38 silver badges67 bronze badges 1
  • using window.find will poke the view html, not the model text content, which is only exposed via the API, so you need to use the codemirror API. there are also search plugins to peruse/modify. it's also under [F3]... – dandavis Commented Jan 1, 2015 at 22:59
Add a ment  | 

1 Answer 1

Reset to default 7

You don't want to simulate the actual key press. Rather, simply run CodeMirror's find mand using execCommand, as in http://jsfiddle/cb1fd72k/1/

发布评论

评论列表(0)

  1. 暂无评论