我可以在(加载的)页面上运行我自己的 javascript 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11464019/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I run my own javascript on a (loaded) page?
提问by Radek
Can I run my own javascript code in a browser when viewing a page?
查看页面时,我可以在浏览器中运行我自己的 javascript 代码吗?
For example I have page index.html. In that I want to run this javascript function
例如我有页面 index.html。因为我想运行这个 javascript 函数
function myFunction()
{
alert("Say Hi");
}
I want to call this function through some browser interface because I don't have access to the source code of the web.
我想通过一些浏览器界面调用这个函数,因为我无法访问网络的源代码。
采纳答案by Jordan Running
Yes. Just how depends on which browser you're using:
是的。具体如何取决于您使用的浏览器:
For Chrome and Safari you'll use the built-in Web Inspector—see the instructions on this page.
Firefox has the built-in Web Console, but the more advanced add-on Firebugis very popular.
The Internet Explorer equivalent is Developer Tools, which you can launch with F12.
对于 Chrome 和 Safari,您将使用内置的 Web Inspector — 请参阅此页面上的说明。
Firefox 具有内置的Web Console,但更高级的附加组件Firebug非常受欢迎。
Internet Explorer 等效项是Developer Tools,您可以使用 F12 启动它。
回答by Brad
You can either simply type it into the JavaScript console for your browser, or for trivial things, you can use the javascript:
protocol handler.
您可以简单地将它输入到浏览器的 JavaScript 控制台中,或者对于琐碎的事情,您可以使用javascript:
协议处理程序。
回答by jfriend00
You can use a bookmarklet, the javascript console or a browser plugin to run your own code in an already loaded page.
您可以使用书签、javascript 控制台或浏览器插件在已加载的页面中运行您自己的代码。
Greasemonkeyis a browser plugin for Firefox that provides a framework for running your own javascript code in other web pages that are already loaded.
Greasemonkey是 Firefox 的浏览器插件,它提供了一个框架,用于在已加载的其他网页中运行您自己的 javascript 代码。
回答by chronodekar
One of the first links when searching on google - Get Started With Greasemonkey
在 google 上搜索时的第一个链接之一 -开始使用 Greasemonkey