随笔分类 -  javascript

摘要:function random(leng: number = 6): string { let s = Math.random().toString(36).substring(2, leng + 2) if (s.length < leng) return s + random(leng - s. 阅读全文
posted @ 2024-12-02 14:27 技术探索者 阅读(8) 评论(0) 推荐(0) 编辑
摘要:function deepCopy2<T extends object>(object: T) { return new Promise<T>((resolve) => { const {port1, port2} = new MessageChannel(); port1.postMessage( 阅读全文
posted @ 2024-12-02 14:26 技术探索者 阅读(8) 评论(0) 推荐(0) 编辑
摘要:function copyText(txt: string) { return new Promise((resolve, reject) => { const domCopy = function () { const input = document.createElement('input') 阅读全文
posted @ 2024-12-02 14:24 技术探索者 阅读(26) 评论(0) 推荐(0) 编辑
摘要:function formatPrice(val: string | number, precision: number = 2) { if (typeof val 'string') { let num = parseFloat(val) if (isNaN(num) || num.toStrin 阅读全文
posted @ 2024-12-02 14:23 技术探索者 阅读(12) 评论(0) 推荐(0) 编辑
摘要:第一步,写一个html页面 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>飞机大战</title> <style> body { margin: 0; } canvas { display: block; 阅读全文
posted @ 2024-11-26 17:17 技术探索者 阅读(109) 评论(0) 推荐(0) 编辑
摘要:window.onorientationchange = function () { alert("转动了"); } 阅读全文
posted @ 2011-11-08 16:17 技术探索者 阅读(281) 评论(0) 推荐(0) 编辑
摘要:<html><style id="css"> body{font-family:Verdana;font-size:11px;color:#333;} #win{position:absolute;left:100px;top:100px;width:200px;height:150px;border:1px solid #000;} .title{width:100%;background:#000;height:18px;color:#fff;cursor:hand;} </style> <script> var x0=0 阅读全文
posted @ 2011-10-17 13:58 技术探索者 阅读(188) 评论(2) 推荐(1) 编辑
摘要:function_getSelectedText(){if(window.getSelection){varsel=window.getSelection();if(sel.rangeCount>0){varrange=sel.getRangeAt(0);returnrange;}}else{varrange=document.selection.createRange();returnrange.text;}}return"";} 阅读全文
posted @ 2011-10-12 10:31 技术探索者 阅读(393) 评论(0) 推荐(1) 编辑
摘要:<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><title></title><style>/*让position:fixed在IE6下可用!*/.fixed-top/*头部固定*/{posi 阅读全文
posted @ 2011-08-11 15:19 技术探索者 阅读(188) 评论(0) 推荐(1) 编辑

点击右上角即可分享
微信分享提示