Ignore Javascript on Windows ?– CUSTOMGUI_HTMLVIEWER



  • Hey everyone,

    I'm trying to implement my gitbook.io – Documentation into one of my plugins, but I'm getting this javascript-error on Windows as already raised by @kbar some time ago:

    Re: Tell the HTML Viewer to ignore javascript

    Just wondering if there's a workaround here, I don't not know about..?

    Here's a quick example for the Script-Editor:

    import c4d
    
    class Documentation(c4d.gui.GeDialog):
        def __init__(self, url="https://shareio.gitbook.io"):
            self.url = url
            self.AddGadget(c4d.DIALOG_NOMENUBAR, 0)
            
        def CreateLayout(self):
            self.SetTitle("shareIO – Documentation")
            self.GroupBegin(0, c4d.BFH_SCALEFIT, 0, 1)
            self.GroupBorderSpace(2, 2, 2, 0)
            self.AddGadget(c4d.DIALOG_PIN, 0)
            self.GroupEnd()
            self.browser = self.AddCustomGui(1000, c4d.CUSTOMGUI_HTMLVIEWER, "", c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 200, 200)
            self.browser.SetUrl(self.url, c4d.URL_ENCODING_UTF16)
    
            return True
    
    dlg = Documentation()
    dlg.Open(c4d.DLG_TYPE_ASYNC)
    

    Any hints or help is really appreciated!

    Thanks,
    Lasse



  • Hi,

    I do not think that there is an easy workaround. You could of course fetch the website with Python and then pre-process it with something like BeautifulSoup and rip out everything that smells like JavaScript and then serve the user that version in the HTML viewer. But aside from the ridiculous effort/outcome balance, this approach would also suffer from the fact that many websites won't run properly without JavaScript (something that would also apply to just 'ignoring' JavaScript errors).

    My question would be: Why has it to be Cinema's HTML viewer? Just open the URL in the users default browser.

    Cheers,
    zipit



  • Hi @zipit,

    yeah, I thought that there might not be an easy fix, wanted to ask anyway!

    The user-experience is much better without leaving C4D to browse through the documentation – IMHO. Also, you can dock it to your layout etc. ...

    There are some benefits of implementing it that way, just a litte annoying that it works on macOS and not on Windows. (again) :)

    Cheers,
    Lasse



  • Hi,

    The user-experience is much better without leaving C4D to browse through the documentation – IMHO. Also, you can dock it to your layout etc.

    Pretty subjective and dependent on the content IMHO. If the software just wants to display some static/local HTML that is rather simple, then I am okay with in-software browsers. But for actual complex content I think there is nothing more egregious than an app shoving down your throat its own sh**** browser.

    Just looking at your link: You created a beautiful documentation which deserves to be rendered by a good engine and the user will certainly enjoy it more in its favourite browser rather than some tiny window in Cinema itself which will always be only a shallow copy of what a real browser can do.

    Thats at least how I view it ;)

    Cheers,
    zipit



  • Yeah, I guess I stick to viewing it in the browser then....... :)

    Cheers,
    Lasse



  • Hi @lasselauch sorry for the late reply, I asked about the developer responsible for it.

    On Windows we use the WebView control of the last iteration of iexplore MS shipped for 8.1 - Internet Explorer 11 (user-agent ID: "Trident").
    It supports >most< things other modern browsers do, but sadly not everything...

    Especially the JS support has become a problem since IE11 is missing parts of the ECMA 6 standard and needs 'polyfills' to emulate those.
    Many JS frameworks / libraries don't offer IE11 compatibility and instead rely on the developer to add those polyfills themselves.

    One of the improvements IE11 received back then was the developer console+tools so the user could use those to track > down the JS issues and resolve them."

    I also forwarded your request about the ability to disable Javascript, but so far nothing planned atm, so the only workaround I see is either fix your javascript framework (maybe a huge task) or you can disable your javascript based on the user agent and if it's an IE11.

    Hope this help,
    Cheers,
    Maxime.