Web development
Confirming a URL in Javascript
Tuesday, June 26th, 2007 by DenisHThis is a little tip that I discovered a while ago but which I’m always forgetting, so I thought I’d post it here where I woudn’t lose it! Sometimes you’ll have a link on a web page which actually does something to a database, deletes the current thing for example. In those circumstances you want to have some sort of “Are you sure?” confirmation.
Javascript has a confirm dialog that you can use, but because you can use the return value of a method to determine event bubbling, you can use this really neatly to give optional links as follows:
onclick=”javascript:return confirm(’Are you sure you want to go to our home page ?’)” >Click here to go to home page
And of course you can try it yourself: Click here to go to home page.
If you click OK, then the confirm returns true and the link is followed. If you click Cancel, then confirm returns false and the event isn’t bubbled up to the href handler and so the link isn’t followed and you stay on the same page.
Javascript debugging, Firefox and Drag and Drop
Thursday, May 17th, 2007 by DenisHIn one of my current projects I need to have a table of data that the user can reorder. A quick search of the internet doesn’t turn up any javascript howtos or frameworks that allow dragging and dropping of table rows, so I had to role my own. I’ve written an article about how to do it, here. (more…)
Firefox development toolbar
Wednesday, October 4th, 2006 by DenisHA friend recently pointed me to a useful development toolbar for Firefox. It’s similar to the development toolbar here but does even more stuff.
You can find the toolbar at http://chrispederick.com/work/webdeveloper/.
Definitely worth having if you’re working with Firefox (in fact I often use Firefox for debugging Javascript and the like because it tends to be much more helpful than IE!).
xml:space="preserve" and xsl:attribute
Wednesday, September 27th, 2006 by DenisHJust a quick tip about xsl which I haven’t found anywhere else…
I wanted to generate some human (well me) readable XML using XSL and found that if you add xml:space=”preserve” to the opening
Subscribe to news from Isocra