Subscribe to our feed

Symfony Experts

Symfony Experts
If you have an urgent question for a symfony-related issue, this is the place to ask.


Stack Overflow

The old fashioned way


  Javascript Articles

July 27, 2009 – 11:07am IE 6 getElementsById() and prototype $() function return dom elements by *name*

I can’t believe I had not run into this yet, but today I had a page that had an element (an anchor) with a name attribute (“floorplans”), and further down the page a div with that id (“floorplans”). When I tried to dynamically load content into my div using $(‘floorplans’), things were getting all out of control on IE 6. Turns out IE6’s document.getElementById returns the first element whose id OR name matches the string, and of course Prototype’s $() function relies on the browser’s own getElementById(). Lesson learned!

July 3, 2009 – 1:11pm Symfony: return javascript response

This is an old trick, but I still find it useful and will post it here in case it will help other symfony developers out there. If you are using the prototype.js library for your ajax requests, the Ajax.Request (and similar) utility methods will automatically evaluate the server’s response as javascript if the response has the ‘text/javascript’ content-type header. More…

Posted by in  Web Development   |     |  Comments Off on Symfony: return javascript response

November 21, 2008 – 5:39pm Javascript get window hash/anchor, get link target

There are two functions I find myself using all the time. They are very useful for javascript events that read the link href attribute to determine an action’s target. More…

Posted by in  Uncategorized   |     |  7 Comments »

October 24, 2008 – 5:01pm IE6 mouseover event not firing, png filter

This took me way too long to figure out. I had a series of div tags that had mousover and mouseout events attached to them using prototype. I couldn’t get these events to fire in IE6 no matter what I tried! Events worked on links, but not any other element.

First thing to check: Are you using the png filter trick?
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop src='/images/white_bg.png');

If so, make sure your mouseover elements have “position:relative” or else the event won’t fire on any element inside another element with the png filter.

This post along got me on the right track.

Posted by in  Uncategorized   |     |  Comments Off on IE6 mouseover event not firing, png filter

June 5, 2008 – 12:50pm Get value of radio button group using prototype

If you want to get the value of the selected element of a radio group, prototype makes this easy. There is more than one way to do it. I’ll update this post as better methods surface. Check out code after the jump.


August 15, 2007 – 3:25am Stereolabels released: updated labels.js for Prototype

Stereolabels unobtrusively places form input labels inside the form inputs themselves. Upon page load, the script crawls the DOM for labels with the specified class name (default is ‘inside’) and places the label text inside the input field. Upon clicking the field, the label is removed. When the element loses focus, if there is no input the label returns. This behavior is only applied to text, textarea, and password input fields.

Information and a download are available in our code section: Stereolabels

Posted by in  Web Development   |     |  Comments Off on Stereolabels released: updated labels.js for Prototype

July 26, 2007 – 11:31am sfCombineFilterPlugin released: Combine js and css requests into single compressed files

The sfCombineFilter plugin automatically combines included js and css files in your web response into one request each, passing the string of file names to a special php file that concatenates them and compresses them for faster delivery. This file is then cached for future use.

Information and download instructions are available in our code section: sfCombineFilter

July 23, 2007 – 8:45pm Prototype Tabs Script released, Scriptaculous Optional

We just released a small script that allows you to easily create tabbed content on your web sites with a nice fade effect. Having searched for a decent script that uses prototype.js and scriptaculous to quickly create tabbed inline content and not having found one, we were inspired to create our own, much as stickmanlabs did with the accordion script. Check out the prototype tabs demo.

Posted by in  Web Development   |     |  5 Comments »

July 19, 2007 – 2:36am Javascript Array Merge: array_merge

Using protoype.js I discovered a quick way to merge to arrays in javascript:

function array_merge(one, two) {
  return one.flatten();

This definitely beats the alternative of iterating through the second array by hand and adding it to the first. Any comments or suggestions are welcome.

Posted by in  Web Development   |     |  9 Comments »

May 14, 2007 – 2:14am javascript urlencode

In doing a google search for javascript urlencode, I realized I was using that terminology just because I was familiar with the PHP function of the same name. Javascript’s method is actually called encodeURI() which will encode all characters except:

, / ? : @ & = + $ #

But what I really wanted to do was get javascript to convert a string that would be okay to put into a query string of a URL. For this, use encodeURIComponent(). This will convert all characters except alphabetic, decimal digits, and:

- _ . ! ~ * ' ( )

That’s more like it. You can view the complete reference at mozilla or w3schools.

Posted by in  Web Development   |     |  5 Comments »