Fixing the ‘onClick’ in Dreamweaver
Here’s a Dreamweaver tip from the ‘fishing with dynamite’ department.
Although it’s not the ideal tool for all tasks, Macromedia Dreamweaver is a very useful tool.
However it has one particularly nasty little habit that has bugged me for a while now — an infuriating penchant for automatically and forcibly converting my perfectly valid ‘onclick’ attributes to a perfectly invalid ‘onClick’ attributes. As far as I can tell, any time a valid onclick is opened in Dreamweaver, it re-parses the page with uppercase ‘C’s in the onclicks. I’ve searched for settings or preferences to disable it, but to no avail.
I briefly considered picking my way through Dreamweaver’s folder structure looking for the guilty file, but with thousands of files, it looked like taking hours. I settled on a brute strength attack. This method has some risk involved and I make no guarantees or promises, other than it worked for me.
1) Firstly I made a copy of my ‘Dreamweaver MX 2004/Configuration’ folder and put it somewhere safe — if it all went pear-shaped this was my salvation.
2) I have used ‘Replace in Files’ from Emurasoft for a while (their little text editor is a tiny gem too). It’s freeware, fast and works, but you may a similar app you prefer. Your call.
3) I set it to find ‘onClick=’ and replace it with ‘onclick=’. I had no idea what type of file I was targeting, so I set the file type to ‘*.*’ — all files. I also turned on the ‘Match Case‘ option and the ‘Search in subfolders‘ and ‘Match only words‘ options.
4) Lastly I pointed it at the Dreamweaver ‘configuration’ folder, crossed my fingers, closed my eyes and hit ‘Replace All’.
One minute later it had finished scanning the nearly 6600 files within that folder, and, as you can see, it found 2676 occurrences of ‘onClick’, which it fixed in nearly 500 files. Gulp. That’s more than I thought…
However, I’m pleased to report that not only has it definitely fixed the problem, but I have no side-effects, breakages or other problems to report in the meantime.
Of course, maybe I just haven’t found them yet.
There is, no doubt, a more elegant solution to this bug, but if it’s an issue for you and you’re feeling brave,..