Probably a loading issue. The HTML snippet is loaded before the part you need, hence the getElementsByClassName("dataViewConversation")[0]; does not find an element. You can of course check this by adding a console.dir(getElementsByClassName("dataViewConversation")[0]); in your JS code, to see if the code actually triggers. It probably is, but too early, hence giving an empty in the console.dir message.
So, best is to add a timeout to the JS script, to make sure the JS script is triggered AFTER the page is loaded.
Hey Jon,
Are you sure that the JavaScript is not only loaded, but also triggered when the page is loaded? Usually you need to trigger the JavaScript somehow for it to be executed. To trigger it onload of the page, you could use something like:
window.onload = function() {
yourFunction(param1, param2);
};
I sounds like your execute JavaScript button makes it trigger just fine, but otherwise it has no reason to be executed.
PS: getElementsByClassName returns a HTMLCollection of elements, so it could be possible that your JavaScript won't allways work. If you want a specific element on a page, use getElementById instead.
Kinds regards,
Bas.