Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Opening the current HTML in a new tab

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 54
    Comment on it

    Here is the exmaple for opening your HTML in a new tab with jQuery, first we define a function for the window in which we take variables for the tab (w) and for HTML (html) that will be opened in a new tab. Then we define a click event from which it will open a tab.

    <script>
      function nWin() {
        var w = window.open();
        var html = $("#toNewWindow").html();
    
        $(w.document.body).html(html);
      }
    
      $(function() {
        $("a#print").click(nWin);
      });
    </script>
    
    
    <div id="toNewWindow">
        <p>Your content here</p>
    </div>
    
    <a href="javascript:;" id="print">Open</a>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: