Run online, copy, save as JS code

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax code copy document function html http javascript

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">


<html xmlns= "http://www.jzread.com/1999/xhtml" >


<head>


<meta http-equiv= "Content-type content=" HTML; charset=gb2312 "/>


<title> Online Run, copy, save as JS code </title>


<style type= "Text/css" >


body,td,th {font-size:12px;}


</style>


</head>


<body>


<script language= "JavaScript" >


var useragent = Navigator.userAgent.toLowerCase ();


var is_opera = useragent.indexof (' opera ')!=-1 && opera.version ();


var is_saf = useragent.indexof (' AppleWebKit ')!=-1 | | Navigator.vendor = = ' Apple Computer, Inc. ';


var IS_WEBTV = useragent.indexof (' WebTV ')!=-1;


var Is_ie = (useragent.indexof (' MSIE ')!=-1 &&!is_opera &&!is_saf &&!IS_WEBTV) && Useragent.substr (Useragent.indexof (' msie ') + 5, 3);


//Run code


function RunCode (obj)


{


var winname = window.open ("," _blank ",");


winname.document.open (' HTML ', ' replace ');


winname.opener = null; Prevent code from talking about page modification


Winname.document.write (Obj.value);


Winname.document.close ();


}


//Save Code


function Savecode (obj) {


var winname = window.open (', ' _blank ', ' top=10000 ');


winname.document.open (' HTML ', ' replace ');


Winname.document.write (Obj.value);


Winname.document.execCommand (' SaveAs ', ', ', ' htmlcode.html ');


Winname.close ();


}


//Copy Code


function Copycode (obj)


{


if (is_ie && obj.style.display!= ' None ')


 {


var rng = Document.body.createTextRange ();


rng.movetoelementtext (obj);


Rng.scrollintoview ();


Rng.select ();


Rng.execcommand ("Copy");


Rng.collapse (FALSE);


 }


}


//Random function


function Rndnum (n)


{


var rnd= "";


for (var i=0;i<n;i++)


Rnd+=math.floor (Math.random () AOE);


return rnd;


}


</script>


<textarea name= "code111" id= "code111" cols= "a" rows= "ten" >111111111</textarea>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.