从URL /地址栏调用Javascript函数 [英] Call Javascript function from URL/address bar

查看:1684
本文介绍了从URL /地址栏调用Javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过URL调用javascript函数?

Is it possible to call a javascript function from the URL?

类似于: 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.

然而, bookmarklets 可以添加书签,以便从地址栏快速运行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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆