I'm interested in knowing how does the text you type on the text box doesn't require a page refresh? Some similar alternatives include:
我很想知道你在文本框中输入的文字如何不需要页面刷新?一些类似的选择包括:
lixlpixel
But they tend to do a page refresh every time a keystroke is pressed...
但是每次按下按键时,它们都会刷新页面...
1 个解决方案
#1
3
They have a Markdown to HTML translator implemented in Javascript. Whenever the content of the 'textarea' changes the preview area is updated with the result of running the Markdown to HTML converter. There's obviously more to it than that -- making this sort of thing perform well can be tricky -- but that's the essence of it.
他们在Javascript中实现了Markdown to HTML translator。每当'textarea'的内容发生更改时,预览区域都会更新,其结果是运行Markdown to HTML转换器。显然还有更多 - 让这种事情表现得很好可能会很棘手 - 但这才是它的本质。
If you inspect the textarea in a browser like Safari you can see that they are using Javascript event handlers for drop, input, keydown, keypress, keyup, mousedown and paste events. When one of these events happen the script responds appropriately, including to run the Javacript Markdown-to-HTML converter and putting the resulting HTML into the preview area.
如果您在Safari等浏览器中检查textarea,您可以看到他们正在使用Javascript事件处理程序来执行drop,input,keydown,keypress,keyup,mousedown和paste事件。当其中一个事件发生时,脚本会做出相应的响应,包括运行Javacript Markdown-to-HTML转换器并将生成的HTML放入预览区域。
#1
3
They have a Markdown to HTML translator implemented in Javascript. Whenever the content of the 'textarea' changes the preview area is updated with the result of running the Markdown to HTML converter. There's obviously more to it than that -- making this sort of thing perform well can be tricky -- but that's the essence of it.
他们在Javascript中实现了Markdown to HTML translator。每当'textarea'的内容发生更改时,预览区域都会更新,其结果是运行Markdown to HTML转换器。显然还有更多 - 让这种事情表现得很好可能会很棘手 - 但这才是它的本质。
If you inspect the textarea in a browser like Safari you can see that they are using Javascript event handlers for drop, input, keydown, keypress, keyup, mousedown and paste events. When one of these events happen the script responds appropriately, including to run the Javacript Markdown-to-HTML converter and putting the resulting HTML into the preview area.
如果您在Safari等浏览器中检查textarea,您可以看到他们正在使用Javascript事件处理程序来执行drop,input,keydown,keypress,keyup,mousedown和paste事件。当其中一个事件发生时,脚本会做出相应的响应,包括运行Javacript Markdown-to-HTML转换器并将生成的HTML放入预览区域。