I know this is a question much discussed but I can\'t figure out why it does not work for me.
This is my function:
function ShowComments(){
alert(\
Some parenthesis are missing.
Change
window.location.href = "/comments.aspx?id=" + movieShareId.textContent || movieShareId.innerText + "/";
to
window.location = "/comments.aspx?id=" + (movieShareId.textContent || movieShareId.innerText) + "/";
No priority is given to the || compared to the +.
Remove also everything after the window.location assignation : this code isn't supposed to be executed as the page changes.
Note: you don't need to set location.href. It's enough to just set location.