简体   繁体   中英

webview.executeJavascript function cannot find jquery- Electron

I am loading a webview and on dom-ready I execute a function inside the webview like this:

webview.executeJavaScript("$('body').css({'left': '" + left + "', 'top':  '" + top + "' })" );

The problem is that webview cannot find reference to $. But I have jquery in my project. What could be the problem ?

Check out this stackoverflow question . You might just need to tell webview that you want to execute JQuery with something like this:

webview.executeJavaScript("jquery:function($('body').css({'left': '" + left + "', 'top':  '" + top + "' }))" );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM