From 0f4c098d6bf83ef5e35cfb834349e56193a261f9 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 7 Aug 2022 21:51:52 +0800 Subject: [PATCH] fix #11 --- src/webgui.nim | 6 +++--- src/webview.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/webgui.nim b/src/webgui.nim index f63cb16..e15d9fa 100644 --- a/src/webgui.nim +++ b/src/webgui.nim @@ -111,7 +111,7 @@ const if (typeof $2 === 'undefined') { $2 = {}; } - $2.$1 = (arg) => { + $2.$1 = function (arg) { window.external.invoke( JSON.stringify( {scope: "$2", name: "$1", args: JSON.stringify(arg)} @@ -123,7 +123,7 @@ const if (typeof $2 === 'undefined') { $2 = {}; } - $2.$1 = (arg) => { + $2.$1 = function (arg) { window.external.invoke( JSON.stringify( {scope: "$2", name: "$1", args: JSON.stringify(arg)} @@ -135,7 +135,7 @@ const if (typeof $2 === 'undefined') { $2 = {}; } - $2.$1 = () => { + $2.$1 = function () { window.external.invoke( JSON.stringify( {scope: "$2", name: "$1", args: ""} diff --git a/src/webview.h b/src/webview.h index 2ff9531..f6d31c8 100644 --- a/src/webview.h +++ b/src/webview.h @@ -138,11 +138,11 @@ struct webview_dispatch_arg { "3C%2Fbody%3E%0A%3C%2Fhtml%3E" #define CSS_INJECT_FUNCTION \ - "(function(e){var " \ + "(function(e){window.onload = function(){var " \ "t=document.createElement('style'),d=document.head||document." \ "getElementsByTagName('head')[0];t.setAttribute('type','text/" \ "css'),t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document." \ - "createTextNode(e)),d.appendChild(t)})" + "createTextNode(e)),d.appendChild(t)}})" static const char *webview_check_url(const char *url) { if (url == NULL || strlen(url) == 0) {