Skip to content

Author: admin@master

Check url content type with javascript

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.

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>. I&#82…

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…

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 …