diff --git a/src/pyj/book_list/comments_editor.pyj b/src/pyj/book_list/comments_editor.pyj index 9116e17051..eba17a4308 100644 --- a/src/pyj/book_list/comments_editor.pyj +++ b/src/pyj/book_list/comments_editor.pyj @@ -287,7 +287,7 @@ class CommentsEditorBoss: 'exec_command': self.exec_command, 'focus': self.focus, } - self.comm = IframeClient(handlers) + self.comm = IframeClient(handlers, 'comments-editor-iframe') def initialize(self, data): window.onerror = self.onerror diff --git a/src/pyj/iframe_comm.pyj b/src/pyj/iframe_comm.pyj index 280642058c..6f29279b0c 100644 --- a/src/pyj/iframe_comm.pyj +++ b/src/pyj/iframe_comm.pyj @@ -173,10 +173,14 @@ def create_wrapped_iframe(handlers, bootstrap_text, entry_point, kw): return iframe, ans +client_instance_num = 0 + class IframeClient: - def __init__(self, handlers): + def __init__(self, handlers, name): self.encrypted_communications = False + self.name = name + self.instance_num = v'++client_instance_num' self.handlers = {k: handlers[k] for k in handlers} self.initialize_handler = handlers.initialize self.handlers.initialize = self.initialize @@ -233,6 +237,7 @@ class IframeClient: def send_message(self, action, data): data.action = action + data.iframe_id = f'{self.name}-{self.instance_num}' if self.encrypted_communications: data = self.gcm_to_parent.encrypt(JSON.stringify(data)) window.parent.postMessage(data, '*') diff --git a/src/pyj/read_book/footnotes.pyj b/src/pyj/read_book/footnotes.pyj index 7c14bad2b3..0938385176 100644 --- a/src/pyj/read_book/footnotes.pyj +++ b/src/pyj/read_book/footnotes.pyj @@ -191,7 +191,7 @@ class PopupIframeBoss: 'clear': self.on_clear, 'display': self.display, } - self.comm = IframeClient(handlers) + self.comm = IframeClient(handlers, 'popup-iframe') self.blob_url_map = {} self.name = None self.frag = None diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj index 832bf082a8..4954aec0f1 100644 --- a/src/pyj/read_book/iframe.pyj +++ b/src/pyj/read_book/iframe.pyj @@ -169,7 +169,7 @@ class IframeBoss: 'replace_highlights': self.replace_highlights, 'clear_selection': def(): window.getSelection().removeAllRanges();, } - self.comm = IframeClient(handlers) + self.comm = IframeClient(handlers, 'main-iframe') self.last_window_ypos = 0 self.length_before = None