<script type="text/JavaScript"> alimama_pid="mm_11307516_1146824_2589042"; alimama_titlecolor="0000FF"; alimama_descolor ="000000"; alimama_bgcolor="FFFFFF"; alimama_bordercolor="E6E6E6"; alimama_linkcolor="008000"; alimama_bottomcolor="FFFFFF"; alimama_anglesize="0"; alimama_bgpic="0"; alimama_icon="0"; alimama_sizecode="12"; alimama_width=468; alimama_height=60; alimama_type=2; </script> <script src="http://a.alimama.cn/inf.js" type="text/javascript"> </script>
解决了在firefox下直接复制的问题,但执行代码中包含引用js文件的标签,在firefox中则脚本无法下载,不能正确执行。有高手可以切磋下!
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>运行复制保存</title>
- </head>
- <body>
- <script language="JavaScript" type="text/JavaScript">
- //运行文本域代码
- function runCode(id) {
- cod=document.getElementById(id);
- var codcode=cod.value;
- if (code!=""){
- var newwin=window.open('','',''); //打开一个窗口并赋给变量newwin。
- newwin.document.open('text/html','replace');
- newwin.opener = null // 防止代码对论谈页面修改
- newwin.document.write(code); //向这个打开的窗口中写入代码code,这样就实现了运行代码功能。
- newwin.document.close();
- }
- }
- function copyCode(id)
- {
- var text2copy = document.getElementById(id).value;
- if (window.clipboardData)
- {
- window.clipboardData.setData("Text",text2copy);
- }
- else
- {
- var flashcopier = 'flashcopier';
- if(!document.getElementById(flashcopier))
- {
- var divholder = document.createElement('div');
- divholder.id = flashcopier;
- document.body.appendChild(divholder);
- }
- document.getElementById(flashcopier).innerHTML = '';
- var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';//这里是关键
- document.getElementById(flashcopier).innerHTML = divinfo;
- }
- return true;
- }
- function saveCode(id) {
- var tcode=document.getElementById(id).value;
- var winname = window.open('', '_blank', 'top=10000');
- winname.document.open('text/html', 'replace');
- winname.document.writeln(tcode);
- winname.document.execCommand('saveas','','code.html');
- winname.close();
- }
- function createMap(){
- var map2 = new LTMaps("map2");
- map2.centerAndZoom(new LTPoint(11640969,3994940),6);
- var points = new Array();
- points.push( new LTPoint( 11629376 , 3995776 ) );
- points.push( new LTPoint( 11642688 , 3988608 ) );
- points.push( new LTPoint( 11641152 , 3992640 ) );
- var polyLine = new LTPolyLine(points);
- map2.addOverLay(polyLine);
- }
- </script>
- <textarea name="textarea" cols="60" rows="10" id="rn01">
- <html xmlns:v="urn:schemas-microsoft-com:vml">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=GB2312"/>
- <meta name="keywords" content=""/>
- <title>地图</title>
- <style type="text/css">v/:*{behavior:url(#default#VML);}</style>
- <script type="text/javascript" src="http://api.51ditu.com/js/maps.js"></script>
- <script type="text/javascript">
- function createMap(){
- var map2 = new LTMaps("map2");
- map2.centerAndZoom(new LTPoint(11640969,3994940),6);
- var points = new Array();
- points.push( new LTPoint( 11629376 , 3995776 ) );
- points.push( new LTPoint( 11642688 , 3988608 ) );
- points.push( new LTPoint( 11641152 , 3992640 ) );
- var polyLine = new LTPolyLine(points);
- map2.addOverLay(polyLine);
- }
- </script>
- </head>
- <body onload="createMap()">
- <div id="map2" style="width:400px; height:300px;"></div>
- </body>
- </html>
- </textarea>
- <br><input onclick="runCode('rn01')" type="button" value="运行代码" style="cursor:hand">
- <input type=button value="复制" onclick="copyCode('rn01')">
- <input type=button value="保存" onclick="saveCode('rn01')">
- <br/>
- </body>
- </html>