Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

$('.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.

like image 792
vinoth Avatar asked Oct 23 '15 07:10

vinoth


1 Answers

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.

like image 166
Manoj Srivastava Avatar answered Oct 11 '22 22:10

Manoj Srivastava