DEMO code:
<Html> <pead> <title> save another webpage </title> </pead> <body> <OBJECT classid = "CLSID: 8856F961-340A-11D0-A96B-00C04FD705A2 "height =" 0 "width =" 0 "id = WebBrowser> </OBJECT> <input type =" button "value =" "onClick =" WebBrowser. execWB (4, 1) "> </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
The above code can only be used in the IE kernel browser, but you can refer to the following code for saving the code function above.
Copy codeThe Code is as follows:
Function runCode (obj ){
Var winname = window. open (''," _ blank ",'');
Winname.doc ument. open ('text/html ', 'replace ');
Winname. opener = null // prevents code from modifying the parent page
Winname.doc ument. write (obj. value );
Winname.doc ument. close ();
}
Function saveCode (obj ){
Var winname = window. open ('', '_ blank', 'top = 10000 ');
Winname.doc ument. open ('text/html ', 'replace ');
Winname.doc ument. write (obj. value );
Winname.document.execcommand('saveas', '', 'code.htm ');
Winname. close ();
}
Function oCopy (obj ){
Obj. select ();
Js = obj. createTextRange ();
Js.exe cCommand ("Copy ");
Alert ("script home prompt: the code has been copied successfully! ");
}