diff --git a/src/webview/webkitgtk/mod.rs b/src/webview/webkitgtk/mod.rs index cf49acc35..1fc042c72 100644 --- a/src/webview/webkitgtk/mod.rs +++ b/src/webview/webkitgtk/mod.rs @@ -335,7 +335,11 @@ impl InnerWebView { }; // Initialize message handler - w.init("Object.defineProperty(window, 'ipc', { value: Object.freeze({ postMessage: function(x) { window.webkit.messageHandlers['ipc'].postMessage(x) } }) })")?; + let mut init = String::with_capacity(115 + 20 + 22); + init.push_str("Object.defineProperty(window, 'ipc', {value: Object.freeze({postMessage:function(x){window.webkit.messageHandlers[\""); + init.push_str(&window_hash); + init.push_str("\"].postMessage(x)}})})"); + w.init(&init)?; // Initialize scripts for js in attributes.initialization_scripts {