添加仅javascript的书签,而不是URL [英] Add a bookmark that is only javascript, not a URL
问题描述
我认为我不能这样做的原因是因为它可能是一个巨大的安全漏洞,但是这里... ...
I'm thinking that the reason I can't do this is because it might be a huge security hole, but here goes...
我想要我的浏览器上有一个书签(最好是FF3),它只是一段javascript代码。它只会根据当前日期构建一个URL,然后在该URL上执行window.location =。
I want to have a bookmark on my browser (FF3, preferably) that is only a snippet of javascript code. It would merely construct a URL based on the current date and then do a window.location = on that URL.
我知道我可以创建一个页面并保持打开状态我的本地机器,只是这样引用它,但我只是想知道你是否可以绕过这一步,实际上书签的位置真的只是javascript。我本可以发誓这是多年前可能发生的事情,但我找不到任何告诉我现在的方法。
I know that I could make a page and keep it on my local machine and just refer to it that way, but I was just wondering if you could bypass that step and actually have the "location" of the bookmark really just be javascript. I could have sworn that this was possible years ago, but I can't find anything that tells me either way now.
推荐答案
你想要的是一个 bookmarklet ,它们很容易创建,应该适用于大多数主流浏览器。
What you want is a bookmarklet they are easy to create and should work in most major browsers.
编辑:堆栈溢出似乎不允许在站点上下文中创建bookmarklet,基本上你可以创建一个新书签并在位置字段中键入以下内容
Stack overflow seems not to allow creating bookmarklets in the context of the site, basically you can create a new bookmark and type the following in the location field
javascript:window.location='http://www.google.com/search?q='+Date()
获取一个用于搜索谷歌当前日期的书签。
to get a bookmarklet that searches google for the current date.
这篇关于添加仅javascript的书签,而不是URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!