TroyGrosfield.com TroyGrosfield.com

Posts Tagged ‘javascript’

Headline

JQuery Sorting by Attribute Value

Author
by Troy Grosfield
Date
April 25th, 2014
Category
Developer
Story

Since jquery objects are “array-like” and not actual arrays,  things like “sort” raise a few questions after inspecting jquery code.  As of jquery 2.1.0 you notice that “sort” isn’t a document method and diving into the source, you’ll see that it’s for internal use only: // For internal use only. // Behaves like an Array’s … read more

Tags
Comments
No Comments »
Headline

Create a Screenshot Using PhantomJS

Author
by Troy Grosfield
Date
November 27th, 2013
Category
Developer
Story

I found this to be a bit interesting so I thought I would share with others.  My goal was to find a way to automate taking a screenshot of a website.  Below is an example of how to do it in PhantomJS: Install PhantomJS There page pretty much explains everything: http://phantomjs.org/download.html I’m on a Mac … read more

Tags
Comments
No Comments »
Headline

Preventing Character Input Using Javascript

Author
by Troy Grosfield
Date
December 1st, 2010
Category
Developer
Story

The objective here is to prevent a user from typing a specific character in a textbox. This can be accomplished with only a few lines of Javascript. Html Here we create a simple form with a single textbox: <form action=”#”> <input type=”text” /> </form> Javascript Now we add the Javascript to prevent characters from being … read more

Tags
Comments
2 Comments »
Headline

Progressive Enhancement for Web Design

Author
by Troy Grosfield
Date
October 26th, 2010
Category
Developer
Story

If you’re into web development you’ve likely come across the term progressive enhancement. But what does this really mean? Progressive enhancement is a strategy for web design that emphasizes accessibility, semantic HTML markup, and external stylesheet and scripting technologies. Progressive enhancement uses web technologies in a layered fashion that allows everyone to access the basic … read more

Tags
Comments
No Comments »
Headline

Include Images in Your Twitter Widget

Author
by Troy Grosfield
Date
October 13th, 2010
Category
Developer
Story

Update: This script to pull images into the widget no longer works.  Twitter started returning all links including images as a shortened twitter http://t.co url which just redirects to the actual resource.  The bad part about this is you can’t tell if the link is truly an image or not and you can’t reference an … read more

Tags
Comments
9 Comments »
Headline

Encapsulation, Namespacing, and Object Oriented Javascript

Author
by Troy Grosfield
Date
September 15th, 2010
Category
Developer
Story

Global functions and/or variables in Javascript can be very bad at times especially when there are many people working on a single project. In order to prevent naming collisions it’s a good idea to namespace your Javascript functions and variables and focus on encapsulation when needed. Issue Lets say you have multiple Javascript files: common.js … read more

Tags
Comments
3 Comments »
Headline

Javascript and a Link’s Onclick Event

Author
by Troy Grosfield
Date
September 14th, 2010
Category
Developer
Story

I was given the task of making a link appear selected once it was clicked. This needed to be done with Javascript so I thought I would share this easy snippet. Demo Zoom (click link to see in action): Past 7 days Past 30 days Past 3 months Past 6 months Past year You clicked: … read more

Tags
Comments
No Comments »