1

Is there a javascript script that returns the current html of the window? I mean the content of the webinspector or Firebug html tab.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
  • This extension has a "View Generated Source" option which will provide what you're asking: https://addons.mozilla.org/en-US/firefox/addon/web-developer/ – Evan Davis Apr 06 '12 at 17:50
  • 1
    possible duplicate of [Get entire document HTML as string](http://stackoverflow.com/questions/817218/get-entire-document-html-as-string) – Matt Ball Apr 06 '12 at 17:52

2 Answers2

1

Yes -- this has been discussed previously here on StackOverflow:

How to get the entire document HTML as a string?

In short,

var txt = document.documentElement.innerHTML;
alert(txt);
Community
  • 1
  • 1
Authman Apatira
  • 3,994
  • 1
  • 26
  • 33
0

try this example, it is useful for you

       <html>

      <style type="text/css">
       body {
         margin: 3em;
          }

   #Wrapper {
   background: #aaa;
   min-width: 200px;
   padding: 10px;        
  }

    #Panel {
   width: 300px;
   background: green;
    position:absoulte;
  }
</style>

  <script language="javascript" type="text/javascript">

  function CallPrint(strid)
    {
     var prtContent = document.getElementById(strid);
var WinPrint = window.open('', '',    'left=30,top=0,width=600,height=600,toolbar=1,scrollbars=1,status=0');

           var ss='<html><body>' + prtContent.innerHTML + '</html></body>';
          alert(ss);
       WinPrint.document.write(ss);

            WinPrint.document.close();



     }

  </script>
    <body>

    <div id="Wrapper">
     <div id="first">Panel</div>
   <div id="second">Panel</div>
   <div id="third">Panel</div>
   <div id="fourth">Panel</div>
   <a href="#" onClick="CallPrint('Wrapper');">Click TO View Full Html</a>
      </div>
      </body>
     </html>
srini
  • 876
  • 3
  • 12
  • 23