window.open target _self v window.location.href?

2024-02-13

我需要使用 JavaScript 重定向用户。哪种方法是首选方法?

window.open("webpage.htm", "_self");

or

window.location.href = "webpage.htm";

当然,第二种方法是首选,因为您没有另一个函数调用的开销:

window.location.href = "webpage.htm";
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

window.open target _self v window.location.href? 的相关文章

随机推荐