Javascript bookmarklet转到URL并执行 [英] Javascript bookmarklet go to URL and execute
问题描述
我有一个这样的javascript,使用ia书签:
I have a javascript like this, used i a bookmarklet:
window.location="URL"
document.getElementById('username-id').value = 'User'
document.getElementById('pwd-id').value = 'pass'
doLogin();
问题是javascript会在点击网址后立即停止。
如何使其进入页面并执行脚本?
The problem is that javascript stops as soon as it hits the URL. How to make it go to a page and execute a script?
任何帮助将不胜感激。
推荐答案
不幸的是,您的书签将无法正常工作。更改 window.location
结果加载新页面 - 您不能在该页面上执行任何Javascript,而不首先显示文档。
Unfortunately your bookmarklet will not work. Change of window.location
results loading of the new page - you cannot execute any Javascript on that page without having the document present first.
可以通过浏览器扩展来实现所需的操作,例如Greasemonkey脚本,在页面加载时执行指定的Javascript。
The desired action can be achieved by browser extensions, e.g. Greasemonkey script, which execute specified Javascript on the page upon page load.
这篇关于Javascript bookmarklet转到URL并执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!