自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

前端開(kāi)發(fā)中這些小技巧,你知道幾個(gè)?

開(kāi)發(fā) 前端
本篇就給你介紹一下前端開(kāi)發(fā)中的這些技巧,以及相關(guān)的工具,希望對(duì)你有所幫助!

[[402834]]

瀏覽器地址欄運(yùn)行JavaScript代碼

  1. javascript:alert('hello!'); 
  • Firefox不支持;
  • 其他瀏覽器必須手動(dòng)輸入才可執(zhí)行;

瀏覽器地址欄運(yùn)行HTML代碼

  1. data:text/html,<h1>Hello, world!</h1> 
  • 在非IE瀏覽器可以運(yùn)行

瀏覽器變成文本編輯器

地址欄輸入:

  1. data:text/html, <html contenteditable> 

控制臺(tái)輸入:

  1. document.body.contentEditable='true'

利用a標(biāo)簽自動(dòng)解析URL

  1. var a = document.createElement('a'); 
  2. a.href = 'https://www.maomin.club'
  3. console.log(a.host); // www.maomin.club 

頁(yè)面擁有ID的元素會(huì)創(chuàng)建全局變量

  1. <!DOCTYPE html> 
  2. <html> 
  3. <head> 
  4.  <title></title> 
  5. </head> 
  6. <body> 
  7. <div id="app">我是內(nèi)容</div> 
  8. <script type="text/javascript"
  9.  console.log(app.textContent) // 我是內(nèi)容 
  10. </script> 
  11. </body> 
  12. </html> 

引用CDN文件時(shí),不用HTTP標(biāo)識(shí)

  1. <script src="//cdn.bootcdn.net/ajax/libs/vue/3.0.11/vue.cjs.js"></script> 

利用script標(biāo)簽保存任意信息

  1. <script type="text" id="template"
  2.  <h1>This won't display</h1> 
  3. </script> 
  4. <script type="text/javascript"
  5.  const text = document.getElementById('template').textContent; 
  6.  console.log(text); // <h1>This won't display</h1> 
  7. </script> 

 在頁(yè)面中隱藏鼠標(biāo)

  1. *{ 
  2.     cursor: none!important; 

文字模糊效果

  1. p { 
  2.     color: transparent; 
  3.     text-shadow: #111 0 0 5px; 

 實(shí)時(shí)編輯CSS

  1. <!DOCTYPE html> 
  2. <html> 
  3. <head> 
  4.  <title></title> 
  5.  <style type="text/css"
  6.   style{ 
  7.    display: block; 
  8.   } 
  9.  </style> 
  10. </head> 
  11. <body> 
  12.     <style  contentEditable> 
  13.          body { color: blue } 
  14.     </style> 
  15. </body> 
  16. </html> 

實(shí)現(xiàn)長(zhǎng)寬比固定區(qū)域

  1. <div style="width: 100%; position: relative; padding-bottom: 56.25%;"
  2.     <div style="position: absolute; left: 0; top: 0; right: 0; bottom: 0;background-color:yellow;"
  3.         this content will have a constant aspect ratio that varies based on the width. 
  4.     </div> 
  5. </div> 

禁止他人使用iframe標(biāo)簽引用網(wǎng)址

  1. if (window.location != window.parent.location) window.parent.location = window.location; 

生成隨機(jī)字符串

  1. function generateRandomAlphaNum(len) { 
  2.     var rdmString = ""
  3.     for (; rdmString.length < len; rdmString += Math.random().toString(36).substr(2)); 
  4.     return rdmString.substr(0, len); 

浮點(diǎn)數(shù)轉(zhuǎn)化為整數(shù)

  1. console.log(~~1.2); // 1 

 

責(zé)任編輯:姜華 來(lái)源: 前端歷劫之路
相關(guān)推薦

2019-07-25 10:45:05

GitHub技巧網(wǎng)站

2021-10-25 14:55:38

Linux技巧命令

2021-02-27 17:13:21

前端代碼邏輯

2022-05-05 12:02:45

SCSS函數(shù)開(kāi)發(fā)

2020-02-23 23:29:07

Python編程開(kāi)發(fā)

2024-02-26 00:00:00

前端工具Space.js

2020-10-28 11:20:55

vue項(xiàng)目技

2024-01-29 00:51:39

前端開(kāi)發(fā)利器

2022-09-15 07:05:09

Windows電腦技巧

2024-09-05 09:25:59

SpringUserDAO接口

2018-09-20 17:05:01

前端程序員JavaScript

2022-04-28 12:17:26

瀏覽器連字符hyphens

2019-09-25 09:05:52

Python 機(jī)器學(xué)習(xí)編程語(yǔ)言

2023-11-23 10:21:37

2022-09-06 08:07:24

SQL語(yǔ)句查詢

2019-10-29 08:44:47

Java數(shù)據(jù)庫(kù)實(shí)體

2023-12-15 10:42:05

2013-04-09 11:26:55

WindowsPhon

2022-04-06 07:32:41

Java運(yùn)算符變量

2022-04-15 09:01:18

前端工具UTF8編碼
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)