window.open target _self v window.location.href? [英] window.open target _self v window.location.href?
本文介绍了window.open target _self v window.location.href?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用JavaScript重定向用户。哪个是首选方法?
I need to redirect the user using JavaScript. Which is the preferred method?
window.open("webpage.htm", "_self");
或
window.location.href = "webpage.htm";
推荐答案
绝对是第二种方法,因为你没有有另一个函数调用的开销:
Definitely the second method is preferred because you don't have the overhead of another function invocation:
window.location.href = "webpage.htm";
这篇关于window.open target _self v window.location.href?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文