最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to open the content inside a DIV tag in new tab - Stack Overflow

programmeradmin2浏览0评论
$('.menu div.profile-btn').on('click', function () {
    $('.mainservice-page').fadeIn(1200);
}

The above script opens the contents of the div .mainservice-page successfully, but I want to open them in a new tab.

How can I do that?

Thanks in advance.

$('.menu div.profile-btn').on('click', function () {
    $('.mainservice-page').fadeIn(1200);
}

The above script opens the contents of the div .mainservice-page successfully, but I want to open them in a new tab.

How can I do that?

Thanks in advance.

Share Improve this question edited Jan 3, 2017 at 20:55 Suhas Srivats Subburathinam 4251 gold badge6 silver badges19 bronze badges asked Oct 23, 2015 at 7:23 vinothvinoth 751 gold badge1 silver badge5 bronze badges 3
  • Do you mean browser tab? – Lucius Commented Oct 23, 2015 at 7:24
  • Here's a similar thread: stackoverflow./questions/3841100/… – Thamilhan Commented Oct 23, 2015 at 7:26
  • Did you open any URL or you want to open only content in new tab of browser ? Means this class "mainservice-page" contains a plete page or just content. – Manoj Srivastava Commented Oct 23, 2015 at 7:27
Add a ment  | 

1 Answer 1

Reset to default 6

You can do like that :

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();

});

Hope this will help you.

发布评论

评论列表(0)

  1. 暂无评论