原文: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>