定位与拖动 iframeApril 06, 2017

定位 iframe 在写一个划词翻译扩展 Saladict 时,有一个需求:用户选择一段文本之后,会在鼠标附近显示一些元素。 这个初看很简单,监听一个 mouseup 事件,获取 clientX 和 clientY 就行。这也是 Saladict 前几版用的方法。 但这个方法有个缺陷:iframe 里的鼠标事件不会传到父窗口上。 解决方法也很简单,就难在把它们都联系起来。 iframe…

#Recommended#iframe#JavaScript#postMessage#Drag#Extension

Position and Drag iframeApril 06, 2017

Position in iframes I wrote a Chrome extension Saladict, an inline translator, which involved such requirement: When user makes a text selection, something will pop up nearby the cursor. It looks…

#Recommended#iframe#JavaScript#postMessage#Drag#Extension

eat();

sleep();

code();

repeat();