doPostback failing in IE 11+ Windows 8.1

We have created a new “ie11.browser” file in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\Browsers and now ASP.NET is working correctly. After creating the file we run “aspnet_regbrowsers -i” and restarted IIS. We simply copied the capabilities of IE6-9. We do not know if this is accurate, but ASP.NET is now working with Explorer 11 running on Windows 8.1 Our ie11.browser … Read more

Renaming object keys recursively

There are a couple of problems there. One is that you’re falling prey to The Horror of Implicit Globals by failing to declare your build variable in the function. But the logic has issues as well, here’s a minimal reworking: var keys_short = [“ch”,”d”,”u”,”tz”]; var keys_long = [“children”,”data”,”user_id”,”time_zone”]; function refit_keys(o){ var build, key, destKey, ix, … Read more

HTML5: Detecting if you’re on mobile or pc with javascript? [duplicate]

I was looking into this a few years back. In short, you can’t do this with 100% reliability. There seem to be 2 approaches commonly used to provide a ‘best-guess’: 1. User Agent Detection This is where you check what the client is claiming to be. e.g. if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { // is mobile.. … Read more

Apply color gradient to material on mesh – three.js

Simple gradient shader, based on uvs: var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera(60, 1, 1, 1000); camera.position.set(13, 25, 38); camera.lookAt(scene.position); var renderer = new THREE.WebGLRenderer({ antialias: true }); var canvas = renderer.domElement document.body.appendChild(canvas); var controls = new THREE.OrbitControls(camera, renderer.domElement); var geometry = new THREE.CylinderBufferGeometry(2, 5, 20, 32, 1, true); var material = … Read more

Access webcam without Flash

At the moment of writing this the best solution is WebRTC. It is supported in Chrome, Mozilla and Opera, but still unavaialble in Internet Explorer and Safari. Minimalistic demo. Index.html <!DOCTYPE html> <head> </head> <body> <video></video> <script src=”https://stackoverflow.com/questions/9644612/webcam.js”></script> </body> webcam.js (function () { navigator.getMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia); navigator.getMedia( // constraints {video:true, audio:false}, … Read more

JavaScript while mousedown

You have to invoke the mousedown activity in some reasonable interval. I’d do this: var mousedownID = -1; //Global ID of mouse down interval function mousedown(event) { if(mousedownID==-1) //Prevent multimple loops! mousedownID = setInterval(whilemousedown, 100 /*execute every 100ms*/); } function mouseup(event) { if(mousedownID!=-1) { //Only stop if exists clearInterval(mousedownID); mousedownID=-1; } } function whilemousedown() { … Read more

How to re-execute javascript function after form reRender?

Simplest way is to just put the JS function call in the to-be-updated component itself. <h:form> … <h:commandButton value=”submit”><f:ajax render=”@form” /></h:commandButton> <h:outputScript>someFunction();</h:outputScript> </h:form> This way it’s executed as the page loads and also if the form get updated by ajax. As to the <f:ajax> itself, you could also use its onevent attribute. <f:ajax … onevent=”handleAjax” … Read more

Get drop down value

If your dropdown is something like this: <select id=”thedropdown”> <option value=”1″>one</option> <option value=”2″>two</option> </select> Then you would use something like: var a = document.getElementById(“thedropdown”); alert(a.options[a.selectedIndex].value); But a library like jQuery simplifies things: alert($(‘#thedropdown’).val());