Copying Text to the Clipboard with JavaScript

In the past, using JavaScript to copy and paste text through the clipboard was very cumbersome. While developing NTUST.ME, a short URL service for National Taiwan University of Science and Technology, I wanted to make it easy for people to copy the shortened URLs, so I looked into the clipboard API in JavaScript. I found that newer browsers have an execCommand function that supports many handy text operations, such as copy and select all. Let me introduce it to you! ...

December 10, 2016 · 2 min

【jQuery】Lazyload - Delayed Image Loading

Photography websites often have a lot of images. When visitors browse these sites, it takes quite a while to load because so many photos have to be loaded. This has a big impact on the website’s host traffic, and it also increases the CPU time on the visitor’s side a lot. Here I want to introduce Lazyload, a jQuery plugin that delays image loading. In other words, when you enter a website, it doesn’t load all the images at once. It only loads some of them, and as you scroll the browser, it loads “the images in the section you are looking at,” so the page loads faster. ...

April 27, 2011 · 1 min

Generating QR Codes Directly in the Browser With jQuery.qrcode

There are many ways to draw a QR Code. You can write your own function to draw it, or you can use an API someone else provides. For example, using the Google Chat API to generate a QR Code is the API approach. The jquery.qrcode covered in this post uses a function someone else wrote to generate the code. At first I couldn’t tell the difference between jquery.qrcode and the Google Chat API. Later I learned that the Google Chat API sends the data to Google’s servers to generate the code, while jquery.qrcode draws it directly in the browser. ...

April 8, 2011 · 1 min