Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- DOCUMENT.CREATEELEMENT



  Convert HTML to DOM elements using JavaScript

In some cases, one would want to convert a HTML string to the DOM elements so that JavaScript can handle them easily. This is frequently used when one get some data from third party APIs where the data is in HTML format. In JavaScript, there are a couple of ways one can use to convert HTML to DOM elements. DOMParser document.createElement DOMParser DOMParser can parse XML or HTML source stored in a string into a DOM Document. After the conversion, the normal JavaScript call of h...

   JAVASCRIPT,DOMPARSER,DOCUMENT.CREATEELEMENT,HTML,DOM     2017-08-18 22:51:46

  Going Simple with JavaScript

I was making a change to a page that needed to pull from a remote API and make changes to various parts of the page. Sounds like the time to pull out jQuery and Ajax, doesn't it? Instead, I just used old fashioned JavaScript. Actually, I used new fashioned JavaScript. Browsers haven't stood still in the advent of libraries and frameworks. As a result, we can take advantage of those features when we need to bake in a little extra. Some JSONP The first step was to get the JSONP call execu...

   JavaScript,new version,new addition,JSONP,querySelectorAll     2012-03-06 05:22:59

  An alternative way to parse URL in JavaScript

Normally when we need to process URL in JavaScript, we may use the location object. Then we can use location.hostname,location.href,location.port etc to get the information we need. In this post, we will parse an URL with an alternative way. We can use an URL to create a DOM object by calling document.createElement("a"). The complete code is: function parseURL(url) { var a = document.createElement('a'); a.href = url; return { source: url, protocol: a.protocol.replace(':',''), host: a.ho...

   URL,location,parse     2014-03-03 07:05:11

  Load and execute JavaScript

When we load and execute JavaScript in a webpage, there are many points we need to care about because of its design and feature. There are two features about JavaScript execution in a browser: 1). The JavaScript codes will be executed immediately once loaded;2). When JavaScript codes are being executed, they will block the following contents (including page rendering and other resources downloading). So if there are multiple js files to be loaded, these codes will be executed sequentially. Since...

   JavaScript,async,defer,load,execute     2013-06-07 04:53:46

  IE ActiveX(”htmlfile”) Transport, Part II

In my last post I discussed using the ActiveX(”htmlfile”) technique to provide a usable streaming transport in Internet Explorer. The solution I provided will work, but since writing the last article I’ve made significant progress in understanding why IE behaves the way it does with respect to the streaming transport. The previous solution amounted to creating an array of messages, pushing messages on that array from the htmlfile iframe, and popping messages off of the array i...

   IE,Http,Streaming,htmlfile,Transport,Act     2011-09-05 04:07:02

  Best practices of front end optimization

1. Use DocumentFragment or innerHTML to replace complex elements insertion DOM operation on browser is expensive. Although browser performance is improved much, multiple DOM elements insertion is still expensive and will affect the page load speed. Assume we have an ul element on our page, we now want to retrieve a JSON list using AJAX and then update the ul using JavaScript. Usually we may write it as : var list = document.querySelector('ul'); ajaxResult.items.forEach(function(item) { // ...

   JavaScript,Front end,Optimization,Tips     2013-07-06 11:26:27

  Add page number anywhere in word document

Have you ever frustrated when you want to add page number in a Microsoft word document start from page 2 or later. The way to ease you is to add sections to the word document in which page you want to add page number. The procedures are (in Word 2007) :1. Goto Page Layout->Breaks->Section breaks.2. In Section Breaks zone, you can choose Next Page and some others way to set sections.3. Then when you want to add the page number into next section. Go to Insert->Page Number->Format ...

   Office 2007, Word, Page number, Section,     2011-04-08 04:00:53

  JavaScript efficiency catch up

JavaScript is a very flexible language, we can write JavaScript code freely with various styles, different kinds of codes will have different execution efficiency. Here we summarize some tips we get from our development. Efficiency of JavaScript itself JavaScript has execution context chain, closures, prototype inheritance, eval etc. It brings us some magic features, but it also introduces the performance issue, if we don't use them properly, it will affect the codes execution efficiency. 1. Glo...

   JavaScript,efficiency,event delegation,eval     2013-04-02 04:08:46

  HTML5 photo taking and uploading app implementation

Underthe support of HTML5 standard, Building Web App to take photos is now possible.I will elaborate on how to take photos using Web App, display them on the pageand upload them to the server. 1.     Videostream HTML5 TheMedia Capture API provides the programmable  access to video camera on phones, users canuse the getUserMedia() method to get the video stream provided by video camera.What we need to do is to add a HTML <video> tag and make the videostrea...

   HTML5,Photo taking,Media Capture API ,Implementation     2012-03-15 07:19:49

  How to play with cross domain request

What is cross domain request In simple, cross domain request is to request resource from other domain in one domain. Note, the "other domain" doesn't just mean domain name only, it includes much more. If the protocol, domain name, port is not the same, two domains will be considered different.  Below example describes what is considered as different domain. http://www.a.com/a.jshttp://www.a.com/b.js               # Same domainhttp://www.a.com/lab/a.js &nb...

   FRONT END,JSONP,CROSS DOMAIN,CROSS ORIGIN,CORS,DOCUMENT.DOMAIN,WINDOW.NAME     2016-11-06 00:48:54