Blogger Information
Blog 38
fans 0
comment 1
visits 36097
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
location.href()和location.assign()这两个方法有什么不同呢?
夜澜风的博客
Original
2102 people have browsed it

ocation.href是一个属性,要这样使用:
location.href='http://www.example.com'
而location.assign('http://www.example.com') 就是 location.href='http://www.example.com'
至于
location.replace('http://www.example.com')与前两者的区别是,在replace之后,浏览历史就被清空了(href与assign方法会产生历史记录)。

建议:使用replace。因为前两者会产生历史记录,而浏览者如果点‘后退’按钮,就会产生'redirection loop',会被浏览器禁止。

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post