JSFiddle

  • Using Blob to generate a data url #2 is the latest revision

    No-Library (pure JS), HTML, CSS, JavaScript

    if (!window.BlobBuilder && window.WebKitBlobBuilder) {
        window.BlobBuilder = window.WebKitBlobBuilder;
    }
    
    var csv = "COL,COL,COL\nVal,Val,Val";
    var contentType = "text/csv";
    
    var rawLength = csv.length;
    var ...
  • Border highlighting on hover #2 is the latest revision

    No-Library (pure JS), HTML, CSS, JavaScript

    <table>
        <tr><td>hello</td></tr>
        <tr><td>hello</td></tr>
        <tr><td>hello</td></tr>
    </table>
    
    <ul>
        <li>hello</li>
        <li>hello</li>
        <li>hello</li>
    </ul>
  • Checks for IE8 normalising with dojo

    Dojo 1.9.0, HTML, CSS, JavaScript

    var div = document.body.appendChild(
        document.createElement('div'));
    
    require(['dojo/on'], function (on) {
        on(div, "click", function (e) {
            alert(typeof ...
  • Proof of using query().place in dojo when no items are found in the query

    Dojo 1.9.0, HTML, CSS, JavaScript

    require(['dojo/query', 'dojo/NodeList-traverse'], function(q) {
        
        var div = document.body.appendChild(
            document.createElement('div'));
        
        for(var i = 0; i ...
  • Difference between using innerText and textContent depending on styles applied to outer element

    innerHTML and textContent read from the actual content of the element whereas innerText will apply display styles to the result before returning. Note that the first item in the innerText result is empty whereas the first textContent and first innerHTML both still have the actual value.

    if(![].forEach) { // IE8 doesn't have forEach
        Array.prototype.forEach = function(fn,sc) {
            for(var i=0,l=this.length ...
  • Values of an a[href] to not require preventDefault

    No-Library (pure JS), HTML, CSS, JavaScript

    [].forEach.call(document.querySelectorAll('a'),
    
    function (a) {
        a.addEventListener('click', function (e) {
            console.log("Clicked");
        }, true);
    });
    
    
    window.setInterval(function () {
        document ...
  • Strictness of equality in DOJO array utils indexOf

    Dojo 1.9.0, HTML, CSS, JavaScript

    
    require(['dojo/_base/array'], function(arrayUtils) {
    
        function doIndexOf(container, src, search) {
            document.querySelector(container).appendChild(
                document.createElement('div')
            )
            .innerHTML = 'Index ...
  • Mutating an object in an iterator

    No-Library (pure JS), HTML, CSS, JavaScript

    var obj = {
        foo: "bar",
        bar: "foo"
    };
    
    document.body.appendChild(document.createElement('p'))
            .appendChild(
                    document.createTextNode("Starting: " +JSON.stringify(obj))
            );
    
    for ...
  • What elements can receive focus

    No-Library (pure JS), HTML, CSS, JavaScript

    var focuses = document.querySelectorAll('.focusable');
    var range = document.querySelector('[type=range]');
    range.setAttribute('max', focuses.length);
    
    range.addEventListener('change', function ...
  • Event bubbling difference between Dojo & jQuery

    the Dojo framework does not cater for event bubbling when elements are not in the DOM. jQuery does. Irritating.

    require(['dojo/on', 'dojo/query'], function (on, query) {
        var ul = document.createElement('ul');
        'aaa bbb ccc ddd'.split(' ').forEach(function ...