提交 254d100d 编写于 作者: J Johannes Rieken

improve detection when link becomes active, fixes #5843

上级 a47b167a
......@@ -63,10 +63,15 @@
// script to bubble out link-clicks
const defaultScripts = newDocument.createElement('script');
defaultScripts.innerHTML = `
document.body.addEventListener('click', function (event) {
if(event.target.tagName === 'A' && event.target.href) {
window.parent.postMessage({ command: 'did-click-link', data: event.target.href }, 'file://');
event.preventDefault();
document.body.addEventListener('click', function(event) {
let node = event.target;
while (node) {
if (node.tagName === 'A' && node.href && node.href[0] !== '#') {
window.parent.postMessage({ command: 'did-click-link', data: node.href }, 'file://');
event.preventDefault();
break;
}
node = node.parentNode;
}
});`
newDocument.body.appendChild(defaultScripts);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册