Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on Windows on each run - "appendChild" property cannot be retrieved #11

Open
ThomasTJdev opened this issue May 27, 2020 · 10 comments
Labels
help wanted Extra attention is needed windows

Comments

@ThomasTJdev
Copy link
Collaborator

When running the examples - or creating my own programs - I always encounter the error below:

Translated
There was an error in the script on this page.

The "appendChild" property cannot be retrieved for undefined or null reference.

Continue?

webgui_error

@juancarlospaco
Copy link
Owner

juancarlospaco commented May 27, 2020

It is a known "bug", basically if you target Windows, you have to keep IE compatibility,
theres tools on JavaScript world to compile the JavaScript to older JavaScript compatible with Internet Explorer, like Babel and similar.
Basically of the 3 web engines built in the OS, the Windows one sucks the most.

Honestly I do not know a better way to fix that.
I look for other alternatives and libs to wrap but they tend to use .NET on Windows.
:(

@juancarlospaco juancarlospaco added help wanted Extra attention is needed windows labels May 27, 2020
@bitnom
Copy link

bitnom commented Jun 20, 2020

Wasn't the new Edge built using Chromium as a base? Does it not replace the old IE webview?

edit: I don't quite understand. IE is not Webkit so what does IE have to do with it?

@juancarlospaco
Copy link
Owner

It does not use Chromium, thats why is more light weight than ElectronJS.
:)

@marcomq
Copy link

marcomq commented Oct 10, 2020

I got the same error on the blink example, that doesn't even use Javascript in the HTML part.

This error is from 'CSS_INJECT_FUNCTION' in webview.h
It is the only occurance of appendChild that I could find in the code.

I was able to run the example on windows without error message after making some modifications in the webview.h
I changed the webview.h from

#define CSS_INJECT_FUNCTION                                                    \
  "(function(e){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)})"

to

#define CSS_INJECT_FUNCTION                                                    \
  "(function(e){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))})"

After this, I needed to force to recompile the example with
nim c -r -f example.nim

However, this isn't any permanent solution.
The "blink" text stopped blinking in the application. So there are now issues with inline css. Maybe also other new CSS issues.

The CSS_INJECT_FUNCTION issue in the Webview.h was also in the original Webview code and was never changed. The code doesn't exists in the current webview main branch, as there were massive changes in March. A complete new webview branch was merged that changed webview.h completely: webview/webview@843c3aa#diff-90d68d8f03ac5ea2a94bf99d53d4b9d0

@ThibaudMZN
Copy link

Did you guys manage to fix this ? I'm having exactly the same problem

@bung87
Copy link
Contributor

bung87 commented Aug 7, 2022

@juancarlospaco I think in newWebView result.css should not be called by default. this project main usage is create crossplatorm web based gui, the end developer will use their own design in common, I also notice jsTemplate use arrow function syntax which is not supported in old IE webview, please alteast make this project usable.

@bung87
Copy link
Contributor

bung87 commented Aug 7, 2022

thought appendChild need dom ready, we can simply use onload even there is little different.
I've tested on win11.

#define CSS_INJECT_FUNCTION                                                    \
  "(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)}})"

@juancarlospaco
Copy link
Owner

Pull Request welcome, and will be merged, right now I do not have Windows to test easily.

@bung87 bung87 mentioned this issue Aug 7, 2022
juancarlospaco added a commit that referenced this issue Aug 8, 2022
@CardealRusso
Copy link
Contributor

why it was closed? this error stills persist

@CardealRusso
Copy link
Contributor

Using run_js example, first i get this error
webgui_error

Using @bung87 will prevent this error but it still (even without the fix) a second error happens:
webgui_error

wich wont fully load the js

webgui_error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed windows
Projects
None yet
Development

No branches or pull requests

7 participants