Tuesday, December 15, 2015

IE 9 Compatibility

While searching for ways to ensure IE 9 compatibility in HTML pages, some articles suggest that

Just having <!DOCTYPE html> at the very top of the page with nothing preceding it should be enough to make IE9 use standards mode.

While this is true, I found out that even after having the document type declared as above, few pages in my MVC application were not being rendered properly. While searching more I came across this post

http://stackoverflow.com/questions/27571231/x-ua-compatible-not-working-in-ie-9-for-intranet-sites

Which says that console.log puts IE in quirks mode inspite of doctype and meta tags referring to IE 9. And commenting out all console.log statements really has fixed this issue for me.


Thursday, December 10, 2015

Javascript multithreading

It is interesting to know that multithreading is supported in javascript, though it has to source a different file it is still a relief for very cpu intesive UI operations

This is a demo code for the webworker

<!DOCTYPE html>
<html>
<body>

<p>Count numbers: <output id="result"></output></p>
<button onclick="startWorker()">Start Worker</button>
<button onclick="stopWorker()">Stop Worker</button>
<br><br>

<script>
var w;

function startWorker() {
    if(typeof(Worker) !== "undefined") {
        if(typeof(w) == "undefined") {
            w = new Worker("demo_workers.js");
        }
        w.onmessage = function(event) {
            document.getElementById("result").innerHTML = event.data;
        };
    } else {
        document.getElementById("result").innerHTML = "Sorry! No Web Worker support.";
    }
}

function stopWorker() {
    w.terminate();
    w = undefined;
}
</script>

</body>
</html>
 
and the demo_worker.js contains
 
var i = 0;

function timedCount() {
    i = i + 1;
    postMessage(i);
    setTimeout("timedCount()",500);
}

timedCount();
 

c# httpclient The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

 If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remo...