我想在地址栏中隐藏网址使用代码JavaScript
<script type="text/javascript">
var slug = document.location.pathname;
{
var ncr = "" ;
window.location.replace(ncr);
}
</script>
答案 0 :(得分:0)
您可以通过在历史记录中按其他状态来覆盖地址栏中的位置。但请记住,它会附加到浏览历史记录中。您可以找到here
的更多信息history.pushState({}, null, "overrided.html");
或者替换状态:
history.replaceState({}, null, "overrided.html");
答案 1 :(得分:-1)
这可以获得上下文
var contexto = '/' + window.location.pathname.split("/")[1];