Tag: javascript

jQuery – When to use return false or preventDefault

Ran into a great article that explains the differences between return false, preventDefault and stopPropagation.  Here’s a summary: return false does both preventDefault and stopProgagation preventDefault just stops the browser default event. stopPropagation stops bubbling. In most cases you would

Tagged with: ,

WordPress Widget Image Field

I found a great utility plugin to help with adding a Image picker field to a widget.  Basically you install and activate this plugin and you make your own widget and utilize the image field easily. The only problem I

Tagged with: , ,

Passing parameters to setTimeout in a loop

Problem I know to pass a parameter to a setTimeout function you would use javascript’s “closure” to get it to work: setTimeout(function(){alert(someParameter)}, 1000); However if you are setting someParameter in a loop, setTimeout will always alert the last value set

Tagged with:

jQuery add table row

Problem How do you add a table row using jQuery?  A table has so many different elements in it that things might get screwy.   Solution There is no one statement-to-use-on-all, but the below line is a pretty general answer

Tagged with: ,

Javascript Files with PHP

Below is a great article on getting your PHP to print out a javascript file and including it like any other javascript file.   You basically just have to name the file something like “something.js.php” so that PHP knows to

Tagged with: ,

Caching Issue

Problem: Changed a javascript file, but the browser still detects it.  Take out the javascript file, and the page still runs fine as if it is there.  This is occurring in IE. Solution: Hit f5 a million times.  Clear the

Tagged with: ,

Chain from Cloth Experiment

I needed to make a chain that was free flowing and looked like a real dangling chain.  I remembered Andrew Hoyer’s super cool Cloth Experiment and wanted to adapt it.  It turned out pretty good.  I first limited the points

Tagged with: ,

Blank Images

Problem: When using Canvas and making a image appear with a grayscale when loading, the images sometimes do not display.   Solution: Use “onload” html attribute to change the image source after it gets a chance to load.  Example: http://orasidesign.com/see-what-we-do/

Tagged with: , ,

IE screenSize

Problem: Apparently no one cares about a user’s actual screen resolution.  Usually I don’t too, but in this case I do.  In creating a home page with an image as the background and expands as the user expands their window,

Tagged with: , ,

Slow Javascript in IE

Problem: The menu on this website:  http://www.sohtanaka.com/web-design/side-navigation-tooltip-popup-bubble/ ran fine in IE.  It was quick and worked fine.  On my website however, it ran slooow. Solution: Look for large images that may be loaded.  IE doesn’t seem to handle them very

Tagged with: , , ,
Top