Layui 在新标签中打开页面 / 模拟点击菜单

原文:https://blog.csdn.net/sr_www/article/details/81394365

核心代码:

        //在新标签页中 打开页面
        function newTab(url, tit) {
            if (top.layui.index) {
                top.layui.index.openTabsPage(url, tit)
            } else {
                window.open(url)
            }
        }

网页结构:

测试页面:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>

    <script type="text/javascript">

        //https://blog.csdn.net/sr_www/article/details/81394365

        //在新标签页中 打开页面
        function newTab(url, tit) {
            if (top.layui.index) {
                top.layui.index.openTabsPage(url, tit)
            } else {
                window.open(url)
            }
        }
    </script>


    <a href="javascript:newTab('HtmlPage5.html','详情')" class="layui-btn layui-btn-sm">查看</a>


    <h1>html4</h1>

</body>
</html>
原文地址:https://www.cnblogs.com/guxingy/p/12009089.html