Page 1 of 1

Disable JavaScript

Posted: Tue Apr 08, 2025 11:58 am
by wombats
Hi,

I'm using a popup menu on a WebViewGadget to provide a context menu. The problem is, when the menu is open, the WebViewGadget still responds to the mouse moving, etc., causing issues. I tried DisableGadget, but it didn't work. Is it possible to temporarily disable JavaScript while the menu is open? I imagine I'd then need a way to detect when the menu closes.

I found this: https://developer.apple.com/documentati ... references, but I don't really know how to access it using CocoaMessage.

Re: Disable JavaScript

Posted: Tue Apr 08, 2025 3:49 pm
by wombats
I figured it out:

Code: Select all

webview = CocoaMessage(0, GadgetID(0), "contentView")
config = CocoaMessage(0, webview, "configuration")
preferences = CocoaMessage(0, config, "preferences")
CocoaMessage(0, preferences, "setJavaScriptEnabled:", #False)