从 URL/地址栏调用 Javascript 函数 [英] Call Javascript function from URL/address bar
问题描述
是否可以从 URL 调用 javascript 函数?我基本上是在尝试在我无法访问源代码的页面中利用 JS 方法.
Is it possible to call a javascript function from the URL? I am basically trying to leverage JS methods in a page I don't have access to the source.
类似于:http://www.example.com/mypage.aspx?javascript:printHelloWorld()
我知道如果您将 javascript:alert("Hello World");
放入地址栏中,它会起作用.
I know if you put javascript:alert("Hello World");
into the address bar it will work.
我怀疑这个答案是否定的,只是想知道是否有办法做到这一点.
I suspect the answer to this is no but, just wondered if there was a way to do it.
推荐答案
没有来自超链接,没有.除非页面内部有专门用于此的脚本并且它正在检查某些参数....但是对于您的问题,不,浏览器中没有对此的内置支持.
There isn't from a hyperlink, no. Not unless the page has script inside specifically for this and it's checking for some parameter....but for your question, no, there's no built-in support in browsers for this.
然而,有书签,您可以添加书签以从地址栏中快速运行 JavaScript 功能;不确定这是否满足您的需求,但已经很接近了.
There are however bookmarklets you can bookmark to quickly run JavaScript functions from your address bar; not sure if that meets your needs, but it's as close as it gets.
这篇关于从 URL/地址栏调用 Javascript 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!