Javascript Bookmarklet不会重定向

Javascript Bookmarklet不会重定向,javascript,bookmarklet,Javascript,Bookmarklet,我正在尝试制作一个书签,它会将我记录到画布中,并在加载后转到缩放页面 这是我的代码: This will log in the user into canvas | V javascript:void(location.href='https://pccsk12.instructure.com/login/saml')

我正在尝试制作一个书签,它会将我记录到画布中,并在加载后转到缩放页面

这是我的代码:

This will log in the user into canvas | V javascript:void(location.href='https://pccsk12.instructure.com/login/saml');
setTimeout(()=>{void(location.href='https://pccsk12.instructure.com/courses/9645/external_tools/184');},10000); ^ | This will switch to the zoom page after everything has loaded 这将用户登录到画布 | v javascript:void(location.href=)https://pccsk12.instructure.com/login/saml');
setTimeout(()=>{void(location.href=)https://pccsk12.instructure.com/courses/9645/external_tools/184');},10000); ^ | 加载所有内容后,将切换到缩放页面 但它不起作用。它会登录,但10秒后不会重定向。
我的代码有什么问题?

当您第一次使用
location.href
切换页面时,它会导航到新页面并卸载当前运行的所有Javascript,包括超时。您可以尝试使用在新选项卡中打开登录页,这样它就不会覆盖当前选项卡。它看起来像这样:

javascript:(函数(){
var login=window.open('https://pccsk12.instructure.com/login/saml');
setTimeout(()=>{login.location.href=>https://pccsk12.instructure.com/courses/9645/external_tools/184';}, 10000);
})();

它不工作了。它使用saml页面创建一个新选项卡,然后将bookmarklet单击的页面更改为缩放页面,而不是saml页面。如果您不喜欢,您可以将打开的窗口保存为变量,然后更改该窗口的位置。这不是我的意图,您可以更新您的答案吗?一旦您将浏览器重定向到新页面,脚本环境和DOM都会重置,因此您的setTimeout可能会被删除而不会执行。您应该尝试更改
setTimeout
中的代码,以执行
console.log(“你好,世界!”)
作为我所说内容的进一步证明