为现有网站定制 Javascript

发布于 2024-12-26 16:00:38 字数 161 浏览 2 评论 0原文

我想创建一个 Android 应用程序来查看现有的 Web URL,但是,我还希望 Android 应用程序上的按钮控件能够在网站的上下文中运行自定义 javascript 代码。

关于如何实现这一点有什么想法吗?也许扩展或创建一个自定义 WebView?有什么想法吗?

谢谢

I would like to create an android application which views an existing web URL, However, i would also like the button controls on the android app to be able to run custom javascript code on the website's context.

Any ideas on how to make this happen? Perhaps extend or create a custon WebView?? Any Ideas?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浸婚纱 2025-01-02 16:00:38

在一般浏览器中,您可以通过 url bar 注入执行任意 javascript(如果保存在书签中,也称为 bookmarklet)。

// first load your normal page, then do this
WebView.loadUrl("javascript: var x = 1; ");

您可以通过将其粘贴到桌面浏览器 URL 栏中 window.alert("hello") 来测试所有这些。

In browsers in general you can execute arbitrary javascript via url bar injection (also called bookmarklet if saved in bookmarks).

// first load your normal page, then do this
WebView.loadUrl("javascript: var x = 1; ");

You can test all this by pasting this in your desktop browser url bar window.alert("hello").

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文