[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Wed, 30 Nov 2022 13:36:36 -0500 (EST) |
branch: old/qt-info
commit 8ed8e4ebe15424998e5e84032626ef1de153d165
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Tue Apr 9 20:58:22 2019 +0100
* js/info.js (init_ifram) <on_load>: Pass iframe window object
to "click" event handler.
(on_click): Allow window object to be overridden. Use it to get
a type.
See
https://stackoverflow.com/questions/26248599/instanceof-htmlelement-in-iframe-is-not-element-or-object
---
ChangeLog | 9 +++++++++
js/info.js | 14 ++++++++++----
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 74efbb487d..5a00af57e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2019-04-09 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * js/info.js (init_ifram) <on_load>: Pass iframe window object
+ to "click" event handler.
+ (on_click): Allow window object to be overridden. Use it to get
+ a type.
+
+ See
https://stackoverflow.com/questions/26248599/instanceof-htmlelement-in-iframe-is-not-element-or-object
+
2019-04-09 Gavin Smith <gavinsmith0123@gmail.com>
* js/info.js (add_icons): Take a document argument. Add CSS
diff --git a/js/info.js b/js/info.js
index 25cc2af28c..e19d3e17a3 100644
--- a/js/info.js
+++ b/js/info.js
@@ -1334,7 +1334,8 @@
/* This function is in the scope of the top-level window, not the
iframe. All attributes of window need to be accessed via the w
- variable. */
+ variable. This applies even for types, so we need to write
+ 'instanceof w.Element' instead of just 'instanceof Element'! */
/* We don't pass in the window as as an argument to init_iframe,
because contentWindow isn't defined immediately after the iframe
element is created. */
@@ -1344,7 +1345,9 @@
/* Add these event listeners which are not otherwise added. */
w.addEventListener ("message", on_message, false);
w.addEventListener ("beforeunload", on_unload, false);
- w.addEventListener ("click", on_click, false);
+ w.addEventListener ("click",
+ function (event) { on_click(event, w) },
+ false);
w.addEventListener ("keyup", on_keyup, false);
}
else
@@ -1407,11 +1410,14 @@
/** Handle click events. */
function
- on_click (event)
+ on_click (event, win)
{
+ if (typeof win == "undefined")
+ win = window;
+
for (var target = event.target; target !== null; target =
target.parentNode)
{
- if ((target instanceof Element) && target.matches ("a"))
+ if ((target instanceof win.Element) && target.matches ("a"))
{
var href = target.getAttribute ("href");
if (href)
- [no subject], (continued)
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject],
Gavin D. Smith <=
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30