Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 views
in Technique[技术] by (71.8m points)

javascript - 从URL /地址栏调用Javascript函数(Call Javascript function from URL/address bar)

Is it possible to call a javascript function from the URL?(是否可以从URL调用javascript函数?)

I am basically trying to leverage JS methods in a page I don't have access to the source.(我基本上是在无法访问源代码的页面中尝试利用JS方法。) Something like: http://www.example.com/mypage.aspx?javascript:printHelloWorld()(类似于: http://www.example.com/mypage.aspx?javascript:printHelloWorld() : http://www.example.com/mypage.aspx?javascript:printHelloWorld() javascript: http://www.example.com/mypage.aspx?javascript:printHelloWorld()) I know if you put javascript:alert("Hello World");(我知道您是否放置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.(我怀疑对此的答案是否定的,只是想知道是否有办法做到这一点。)   ask by DazManCat translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.(除非页面中没有专门用于此目的的脚本并且它正在检查某些参数,否则...不是这样,但是对于您的问题,不,浏览器中没有对此的内置支持。) There are however bookmarklets you can bookmark to quickly run JavaScript functions from your address bar;(但是,有些书签可以标记为从地址栏中快速运行JavaScript函数的书签。) not sure if that meets your needs, but it's as close as it gets.(不知道这是否满足您的需求,但是它已经接近了。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...