How to open contents inside a div tag in a new tab

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

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

How can i do this?

Thanks in advance.

+5
source share
1 answer

You can do this:

 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 helps you.

+5
source

Source: https://habr.com/ru/post/1234348/


All Articles