问题描述
我正在尝试制作一个书签,它将使我登录到画布并在加载后进入缩放页面
这是我的代码:
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
但是它不起作用。它已登录,但10秒后未重定向。 我的代码有什么问题?
解决方法
首次使用location.href
切换页面时,它将导航到新页面并卸载当前所有正在运行的Javascript,包括超时。您可以尝试使用window.open
在新标签页中打开登录页面,以免覆盖当前标签页。看起来像这样:
javascript:(function(){
var login = window.open('https://pccsk12.instructure.com/login/saml');
setTimeout(() => {login.location.href = 'https://pccsk12.instructure.com/courses/9645/external_tools/184';},10000);
})();