Use JS and PHP to export the page to Word's code:
$ (' #toWord '). Click (function() {setTimeout (function(){ varTime= ' <?php echo $time?> '; varstyle = document.getElementsByTagName (' style ') [0].innerhtml; Style= "<style>" +style+ "</style>"; //Console.log (style); vart = document.getElementById (' Printtext '). innerhtml;//Gets the contents of the word to be generated T= B.encode (style+t);//Cryptographic Operation $.ajax ({URL:"Get.php", data:{"HTML": T, "time": time},//is submitted to get.php type by post:' Post ', Success:function(data) {Console.log (data);//Return to the path, local and server is different varurl = "http" +data.substr (Data.lastindexof (":"))); Console.log (URL); //window.history.go (0); //Window.location.href=url; } }); },2000); });
The code for get.php is this:
<?PHPif(isset($_post[' HTML '])){ $html=$_post[' HTML '];}if(isset($_post[' Time '])){ $time=$_post[' Time '];}//echo $html;$html=Base64_decode($html);classword{functionSave$path,$html) { $data=‘ .$html. ' </div></body>; $this->wirtefile ($path,$data); } functionWirtefile ($FN,$data) { $fp=fopen($FN, "WB"); fwrite($fp,$data); fclose($fp); }} $word=NewWord (); //$html = "AAA". $i; $wordname= ' Taiyuanreports/taiyuan '.$time.‘. Doc; $word->save ($wordname,$html); //Ob_flush ()//flush cache/flush () before each execution; $url= ' http://'.$_server[' server_name '].$_server["Request_uri"]; //127.0.0.1/palm/new2/module/report/taiyuan/get.php; Echo substr($url, 0,-7).$wordname; //echo $url; $url = ' http://127.0.0.1/palm/new2/module/report/taiyuan/'; Echo $url. $wordname;?>
In addition, the uploaded server requires permission to succeed.
Export an HTML page as Word