博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
博客园在线运行及一键转载
阅读量:4313 次
发布时间:2019-06-06

本文共 2294 字,大约阅读时间需要 7 分钟。

<script type="text/javascript"> var xmlhttp; var doneStr = loadXMLDoc('https://www.cnblogs.com/liudongpei/p/6021170.html'); function loadXMLDoc(url) { var htmldata; xmlhttp = null; if (window.XMLHttpRequest) { // code for IE7, Firefox, Opera, etc. xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp != null) { xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { // 4 = "loaded" if (xmlhttp.status == 200) { // 200 = "OK" htmldata = get_cnblogs_post_body(xmlhttp.responseText); } else { alert("Problem retrieving XML data:" + xmlhttp.statusText); } } } xmlhttp.open("GET", url, false); xmlhttp.send(null); } else { alert("Your browser does not support XMLHTTP."); } return htmldata; } function state_Change() { if (xmlhttp.readyState == 4) { // 4 = "loaded" if (xmlhttp.status == 200) { // 200 = "OK" //document.getElementById('A1').innerHTML=xmlhttp.status; //document.getElementById('A2').innerHTML=xmlhttp.statusText; //document.getElementById('A3').innerHTML=xmlhttp.responseText; console.log(typeof xmlhttp.responseText); htmldata = get_cnblogs_post_body(xmlhttp.responseText); } else { alert("Problem retrieving XML data:" + xmlhttp.statusText); } } } function get_cnblogs_post_body(str) { var start = str.indexOf("cnblogs_post_body") + 41; var stop = str.indexOf("MySignature") - 15; var getstr = str.substring(start, stop); // 用于提取字符串中介于两个指定下标之间的字符。 //console.log(getstr); return getstr; } window.onload = function() { var newTextarea = document.createElement("textarea"); newTextarea.id = "theCode"; newTextarea.style = "width: 70%; height: 500px;"; newTextarea.value = doneStr; //document.body.appendChild(newTextarea); document.body.querySelector("div").appendChild(newTextarea); //*js复制 document.getElementById('doCopy').addEventListener('click', function() { var cText = document.getElementById('theCode'); var currentFocus = document.activeElement; cText.setSelectionRange(0, cText.value.length); document.execCommand('copy', true); //currentFocus.focus(); }); }; </script> <div> </div> <p> <input id="doCopy" type="button" value="复制代码"> <input οnclick="console.log('theCode')" type="button" value="复制代码"> </p>

          

转载于:https://www.cnblogs.com/7qin/p/10630118.html

你可能感兴趣的文章
数组比较大小的几种方法及math是方法
查看>>
FTP站点建立 普通电脑版&&服务器版
查看>>
js 给一段代码,给出运行后的最终结果的一些综合情况、
查看>>
webservice 详解
查看>>
js自动补全实例
查看>>
VS无法启动调试:“生成下面的模块时,启用了优化或没有调试信息“
查看>>
npm 安装 sass=-=-=
查看>>
WINFORM中加入WPF控件并绑定数据源实现跨线程自动更新
查看>>
C#类对象的事件定义
查看>>
各类程序员学习路线图
查看>>
HDU 5510 Bazinga KMP
查看>>
关于select @@IDENTITY的初识
查看>>
ASP.NET MVC ajax提交 防止CSRF攻击
查看>>
关于CSS伪类选择器
查看>>
适用于带文字 和图片的垂直居中方法
查看>>
Part 2 - Fundamentals(4-10)
查看>>
使用Postmark测试后端存储性能
查看>>
NSTextView 文字链接的定制化
查看>>
第五天站立会议内容
查看>>
CentOs7安装rabbitmq
查看>>