• Implementation of regular script filtering with JS


    (recommended) JS regular knowledge points topic: https://www.jb51.net/article/139831.htm function stripscript(s) {      return s.replace(/<script.*?>.*?<\/script>/ig, ”);  }  Say a little, the master floats by /The content between / is the beginning and end of writing JS regular statements .*? It is a greedy match. If it is not greedy, it is. * match any character, but the greedy one does not contain […]

  • How to track users with JS


    catalogue 1、 Synchronous Ajax 2、 Asynchronous Ajax 3、 Track user clicks 4、 Rebound tracking 5、 Beacon API 6、 Ping attribute 1、 Synchronous Ajax The common method of sending data back to the server is to put the collected user data in the unload event and send it back to the server with Ajax request. However, […]

  • JS how to operate the clipboard API using the clipboard


    catalogue 1、 Document. Execcommand() method (1) Copy operation (2) Paste operation (3) Shortcomings 2、 Asynchronous clipboard API 3、 Clipboard object 3.1 Clipboard.readText() 3.2 Clipboard.read() 3.3 Clipboard.writeText() 3.4 Clipboard.write() 4、 Copy event, cut event 5、 Paste event 1、 Document. Execcommand() method Document. Execcommand () is a traditional method of operating the clipboard and is supported by […]

  • JS method example of mosaicing pictures


    This article mainly introduces an example of JS mosaic method for pictures and shares it with you as follows: Effect demonstration Introduction to canvas This HTML element is designed for client-side vector graphics. It has no behavior, but it presents a drawing API to client JavaScript so that the script can draw everything it wants […]

  • JavaScript implements a drag and drop progress bar


    This example shares the specific code of JavaScript to realize the drag and drop progress bar for your reference. The specific contents are as follows 1、 Progress bar implementation <html> <head> <meta http-equiv=”X-UA-Compatible” content=”IE=edge”> <meta name=”viewport” content=”width=device-width, initial-scale=1″> <meta charset=”UTF-8″> < title > drag progress bar < / Title > <style> body{ margin:50px; ; } […]

  • JS get parameter code


    Copy codeThe code is as follows: function GetQueryString(name) { var reg = new RegExp(“(^|&)” + name + “=([^&]*)(&|$)”,”i”); var r = window.location.search.substr(1).match(reg); if (r!=null) return unescape(r[2]); return null; } alert(GetQueryString(“id”));

  • Native JS encapsulates seamless rotation function


    Native JS encapsulated seamless rotation plug-in for your reference. The specific contents are as follows explain: This is a seamless carousel program written using native JS and Es5 syntax. The relevant APIs are encapsulated in the code, so that after introducing the carousel JS file, you only need to add two lines of code to […]

  • JS to achieve a simple calendar effect


    This example shares the specific code of JS to realize the simple calendar effect for your reference. The specific contents are as follows ##CSS module <style type=”text/css”> *{ margin: 0; padding: 0; } .date{ width: 300px; height: 220px; border: 1px solid #000; margin: 100px auto; } .title{ width: 200px; display: flex; font-size: 12px; margin: auto; […]

  • JavaScript implementation of simple tab bar switching content bar


    This example shares the specific code of JavaScript to realize simple tab bar switching content bar for your reference. The specific contents are as follows HTML + CSS section <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”UTF-8″> <meta http-equiv=”X-UA-Compatible” content=”IE=edge”> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> <title>Document</title> <style> /*Initialize CSS because there is a default margin *{ margin:0; […]

  • JS implementation of Web calculator


    How to use the knowledge of HTML, CSS and JS to make a simple web calculator? A computer has: Computer overall frame Input box Input button Overall computer frame: /*Set div style*/ #showdiv{ border: solid 1px; border-radius: 5px; width: 350px; height: 400px; text-align: center; margin: auto;/* Set center*/ margin-top: 50x; background-color: rgb(214, 219, 190); } […]

  • JSP and JS interaction problem value transfer


    1、 Access the value returned by JS in jsp:Question: Copy codeThe code is as follows: <script language=”javascript”> <!– var str=”123″; <% String aa; %> –> </script> How can AA in this JSP get STR value in JavaScript????To be more specific: Copy codeThe code is as follows: <script language=”javascript”> function returnValue(){ var myform=document.form1; var str=myform.text1.value; <% […]

  • How to write beautiful conditional expressions in JS


    catalogue Multi conditional statement Multi attribute object Replace switch statement Default parameters and Deconstruction Match all or part of the criteria Merge with optional chain and nullash Multi conditional statement Multi conditional statements use array.includes for instance function printAnimals(animal) { if (animal === “dog” || animal === “cat”) { console.log(`I have a ${animal}`); } } […]