I have an anchor within an li element, each with their own onclick handler.
When I manually click the link, which has a # href, both onclick events are fired. This is what I want.
When I click the link by calling document.links[0].onclick(), only the inner onclick event fires.
I cannot change the page itself, only the javascript to be executed.
You are just invoking the function directly – there is no event involved, thus no bubbling. You need to trigger the event instead.