If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

execCommand was originally IE only and may not be available in other browsers.

As mentioned in a previous post, your code that uses getElementById should not run until after the page has loaded and the elements are available to be referred to.

I've checked it in IE9, Chrome (23 I think), and Firefox 18.01. It doesn't work in ANY of them. But like I said before it works fine in all browsers if I use an inline onclick event handler.
Updated code: (NOTE: I am not using jQuery.)

Also, you should definitely not be using tag-names 'ul', 'img' as ids. If you are expecting your dollar function to return the first of these elements (as jQuery does) then you will need to add further code to your dollar function (but still not using them as ids).

And document.onload is not universally supported; presumably you should be using window.onload.

Last edited by AndrewGSW; 01-19-2013 at 09:28 PM.

"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS

through the console. Could that mean the elements haven't loaded yet?
As for the dollar function, I added it as a means of shortening the code. Seemed redundant to keep typing out document.getElementById() when I could simplify it.

Yes, as has been mentioned a couple of times . You need to run the code that attaches events (using getElementById) after the page has loaded. You could either move it into code that runs on the window-load event or move all your JS to the bottom of the page, just before the closing BODY tag.

It is no where near as comprehensive as jQuery's but slightly more flexible than your current version. You can supply it a string (an elements' id), an element-object reference, or several of these separated by commas.

"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS