我想隐藏网址

时间:2017-03-10 15:14:23

标签: javascript

我想在地址栏中隐藏网址使用代码JavaScript

<script type="text/javascript">
var slug = document.location.pathname;
{
var ncr = "" ;

window.location.replace(ncr);
}
</script>

2 个答案:

答案 0 :(得分:0)

您可以通过在历史记录中按其他状态来覆盖地址栏中的位置。但请记住,它会附加到浏览历史记录中。您可以找到here

的更多信息
history.pushState({}, null, "overrided.html");

或者替换状态:

history.replaceState({}, null, "overrided.html");

答案 1 :(得分:-1)

这可以获得上下文

var contexto = '/' + window.location.pathname.split("/")[1];
相关问题