In order to conserve server resources I’m looking for a way to retrieve the content type of a given url using javascript. It should not download the complete content from the url only the headers. Is this possible with the restrictions javascript has. Answer Make an Ajax call with a head request.
Author: admin@master
Multi Level Inheritance in Javascript
I am trying to mock inheritance in Javascript using prototype. I have a function named Model and a type of model => Item. How can I access names array from init() function above? Answer Inheritance in Javascript is tricky! Read this post for a great explanation of traditional object oriented inheritance in…
Lazy Loading HTML5 picture element
I have been searching (unsuccessfully) for a reliable method to lazy load images while using the HTML5 spec for <picture>. Most solutions/plugins out there currently rely on using data- attributes. I could be wrong, but it doesn’t seem this method will work in conjunction w/ <picture>. IR…
jquery – css “transform:scale” affects ‘.offset()’ of jquery
I’m Trying To do Validation in jQuery. It’ll produce error after blur event occurs by checking whether the given input is empty. Based on that, it’ll create a <div class=”errdiv”> next to that input which will have the specific error. I use .offset to get the position of th…
How to programmatically invoke the native datepicker on a mobile device
I want to programmatically kick off the native datepicker on my web page (that is run on iOS and Android). I know that I can use <input type=”date” but that would require user input. How do I kick it off programmatically? Answer You don’t. You can’t tell (/force) the phone to show t…
What is the AutobahnJS realm for?
Just wondering what the mysterious realm field in AutobahnJS is. From the docs, creating a connection is as follows: I don’t set a realm server-side so what is this realm parameter for? Furthermore, it is a required field which must mean it is necessary for the connection to work. Can someone enlighten …
Use HTML5 to resize an image before upload
I have found a few different posts and even questions on stackoverflow answering this question. I am basically implementing this same thing as this post. So here is my issue. When I upload the photo, I also need to submit the rest of the form. Here is my html: Previously, I did not need to resize the image, s…
How can I copy rich text contents to the clipboard with JavaScript?
Premise I need help copying rich text to the clipboard using JavaScript. I have searched around and haven’t found anything to suit my specific needs. Code Problem The aforementioned code isn’t working and is resulting in an object expected error. Any help is appreciated! I have seen a library out …
JavaScript move an item of an array to the front
I want to check if an array contains “role”. If it does, I want to move the “role” to the front of the array. Here, I got the result: [“role”, “email”, “role”, “type”, “name”] How can I fix this? Answer You can sort the array …
Retrieve all selected options from a multi select
I wish to retrieve all selected values. No matter what I try it seems to only give me the value of the selected item that is lowest in the list. So if I select A, B, and C it will only return C. These are the things I have tried: The version of jQuery I am using is v1.9.1 Answer