如何在新选项卡中打开DIV标签内的内容

How to open the content inside a DIV tag in new tab

本文关键字:DIV 标签 新选项 选项      更新时间:2023-09-26
$('.menu div.profile-btn').on('click', function () {
    $('.mainservice-page').fadeIn(1200);
}

上面的脚本成功地打开了div .mainservice-page的内容,但是我想在一个新的选项卡中打开它们。

我该怎么做呢?

提前感谢。

你可以这样做:

function newWindow_method_1() {
  var wi = window.open();
  var html = $('.mainservice-page').html();
  $(wi.document.body).html(html);
}
OR
function newWindow_method_2() {
  var html = $('.mainservice-page').html();
  window.open(html, "__new", "width=1000,height=1000");
}
$('.menu div.profile-btn').on('click', function () { 
  newWindow_method_1();
 // OR
 // newWindow_method_2();
});