简体   繁体   中英

Open New Tab and Close the Current Tab

是否有任何简单的解决方法来关闭当前选项卡并通过 javascript 打开一个新选项卡?

试试下面:

window.open('http://www.google.com','_blank');window.setTimeout(function(){this.close();},1000)

you can use location.replace for same goal: window.location.replace('https://stackoverflow.com/');

https://developer.mozilla.org/en-US/docs/Web/API/Location/replace

window.open(url,'_blank');
this.close();

window.open will open the new tab according to the user browser settings only. Sorry that I didn't find any way to open an url in new tab if the user's browser settings wont allow you to.

In browser settings, set it to allow popups and then try. This will work.

Instead, to disable back button you can use options given in this page

http://www.irt.org/script/311.htm

var win = window.open('/Employees/GetAttendenceDataBySelectedData/?attendDateString=' + $("#AttendDate").val() + ', "_blank');

window.top.close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM