wNim icon indicating copy to clipboard operation
wNim copied to clipboard

[need help]load javascript in webview

Open retsyo opened this issue 3 years ago • 2 comments

this mini html can render mermaid diagram as expected

<!DOCTYPE html>
<html>
  <body>

  <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
  <script>
   	mermaid.init({ startOnLoad: false });
  </script>

    Here is one mermaid diagram:

  <div class="mermaid">
        graph LR;
        A --> B
        B --> C
        C --Route--> A
  </div>

</body>

however, the nim code does not render the diagram

import wNim


let app = App(wSystemDpiAware)
let frame = Frame(title="wWebView", size=(640, 460))
let webView = WebView(frame, style=wWvSilent)

webView.html = """
<!DOCTYPE html>
<html>
  <body>

  <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
  <script>
   	mermaid.init({ startOnLoad: false });
  </script>

    Here is one mermaid diagram:

  <div class="mermaid">
        graph LR;
        A --> B
        B --> C
        C --Route--> A
  </div>

</body>
"""

frame.center()
frame.show()
app.mainLoop()

so what is the way to fix it? Thanks.

retsyo avatar Sep 09 '22 04:09 retsyo

wWebView in wNim use IWebBrowser2, and the last version of browser it supports is deprecated IE11. Dose IE11 support the mermaid.js that you used? (untested)

khchen avatar Oct 16 '22 22:10 khchen

So bad, it seems that IE1 does not support mermaid.js

I am asking because I met a language which claims that HTML+JavaScript can be used to realize UI( https://mp.weixin.qq.com/s/SDrzvtE6YMGmnPBqwdHtcA ), in fact, the demo gifs seem some pretty.

I tested the html page in IE 11(C:\Program Files\Internet Explorer\iexplore.exe) on win 10 64 bits Internet Explorer restricted this webpage from running scripts or ActiveX controls. is prompted. Even I choose enable, only

Here is one mermaid diagram: 
graph LR;A --> BB --> CC --Route--> A 

retsyo avatar Oct 17 '22 13:10 retsyo