美文网首页
JS显示的新文件打开方式

JS显示的新文件打开方式

作者: 云龙789 | 来源:发表于2018-03-03 20:02 被阅读5次
<script>
function open_new_page(user_id) {
        // 在新页面打开
        window.open(document.location.origin + '/user' + user_id);
        // 在本页面打开 还是显示本页面
        window.location.href = document.location.origin + '/user' + user_id;
        //  在本页面打开 显示跳转的页面
        window.top.location.href = document.location.origin + '/user' + user_id;
    }
</script>

document.location.origin是本站域名,比如http://test,这里要实现的打开页面是http://test/user/1

在新页面打开,弹出新窗口的情况实现

window.open('http://www.baidu.com'
, "newwindow", "height=750, width=1285, top=0, 
left="+((window.screen.availWidth-1295)/2)+", toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");

或者

    <a href="/javascript:" onClick="window.open('连接地址','','height=500,width=611,scrollbars=yes,status =yes')">123</a>

相关文章

网友评论

      本文标题:JS显示的新文件打开方式

      本文链接:https://www.haomeiwen.com/subject/xlrxfftx.html