<style> /* Use @media print to adjust the print style you need */ @media print { .noprint { display: none; } } </style> <divclass="print">print</div> <divclass="noprint">noprint</div>
const streamPromise = navigator.mediaDevices.getDisplayMedia() streamPromise.then(stream => { var recordedChunks = [];// recorded video data var options = { mimeType: "video/webm; codecs=vp9" };// Set the encoding format var mediaRecorder = new MediaRecorder(stream, options);// Initialize the MediaRecorder instance mediaRecorder.ondataavailable = handleDataAvailable;// Set the callback when data is available (end of screen recording) mediaRecorder.start(); // Video Fragmentation functionhandleDataAvailable(event) { if (event.data.size > 0) { recordedChunks.push(event.data);// Add data, event.data is a BLOB object download();// Encapsulate into a BLOB object and download } } // file download functiondownload() { var blob = new Blob(recordedChunks, { type: "video/webm" }); // Videos can be uploaded to the backend here var url = URL.createObjectURL(blob); var a = document.createElement("a"); document.body.appendChild(a); a.style = "display: none"; a.href = url; a.download = "test.webm"; a.click(); window.URL.revokeObjectURL(url); } })
<style> @media all and (orientation : landscape) { body { background-color: #ff0000; } } @media all and (orientation : portrait) { body { background-color: #00ff00; } } </style>
<divclass="container"> <divclass="item"data-id="1">Invisible</div> <divclass="item"data-id="2">Invisible</div> <divclass="item"data-id="3">Invisible</div> </div> <script> if (window?.IntersectionObserver) { let items = [...document.getElementsByClassName("item")]; // parses as a true array, also available Array.prototype.slice.call() let io = new IntersectionObserver( (entries) => { entries.forEach((item) => { item.target.innerHTML = item.intersectionRatio === 1// The display ratio of the element, when it is 1, it is completely visible, and when it is 0, it is completely invisible ? `Element is fully visible` : `Element is partially invisible`; }); }, { root: null, rootMargin: "0px 0px", threshold: 1, // The threshold is set to 1, and the callback function is triggered only when the ratio reaches 1 } ); items.forEach((item) => io.observe(item)); } </script>