Always use quotation marks for attribute values
HTML does not force you to use quotation marks, but I recommend that you always use it to avoid such problems.
Problem Cause:
By not using quotation marks, the result of your code is:
Assuming "good day" as value of variable $rodapé
onmousemove=window.parent.document.getElementById('calendario_obs').innerText='bom dia>$cont</text>
Browsers will match the quotes:
onmousemove="window.parent.document.getElementById('calendario_obs').innerText='bom">$cont</text>
by cutting dia'
and ignoring it;
or
onmousemove="window.parent.document.getElementById('calendario_obs').innerText='bom" dia>$cont</text>
By cutting dia
, removing the single quotation marks from the end and putting it as a new attribute in the idle tag.
As JS disregards this "orphan" single quotation mark (as it is in 'bom
), it tries to look for bom
as being a variable, then it will give the variable undefined (you can check it on the console, possibly it will be there) .
How to fix:
Just add the quotation marks around the entire JS code.
Your code should then be:
onmousemove = "window.parent.document.getElementById('calendario_obs').innerText='$rodape'">$cont</text>
When can I not use quotation marks?
When your attribute does not contain ANY space, the attribute's separation in the tag is made by it.