beetle
02-13-2003, 04:37 PM
For the sake of this post, I'll just show the basics of this "problem". Here's a simple function...function makeButton( val )
{
var b = document.createElement( "input" );
b.type = "button";
b.value = val;
document.body.appendChild( b );
}Just makes a button with the specified value, right? Well, if I want the value to contain an entity, such as » i just pass it that when I call the functionmakeButton( "»" );I know what you're thinking, "What's the problem?", because everyting above works as expected. Here's the weird part: If the entity is hard-coded into the function, it doesn't work. So, function makeButton()
{
var b = document.createElement( "input" );
b.type = "button";
b.value = "»";
document.body.appendChild( b );
}Dosn't actually insert "»" as the value, but the literal string "»"
Is there some type of translation of the entity that occurs here? Between the function call and execution? I even thought that because the call is in the BODY and the function is in the HEAD that maybe the entity is valuated differently, but after moving the function to the BODY I find this isn't the case.
I'm not really looking for a workaround or anything, just curious as to the nature of this behavior.
:confused:
{
var b = document.createElement( "input" );
b.type = "button";
b.value = val;
document.body.appendChild( b );
}Just makes a button with the specified value, right? Well, if I want the value to contain an entity, such as » i just pass it that when I call the functionmakeButton( "»" );I know what you're thinking, "What's the problem?", because everyting above works as expected. Here's the weird part: If the entity is hard-coded into the function, it doesn't work. So, function makeButton()
{
var b = document.createElement( "input" );
b.type = "button";
b.value = "»";
document.body.appendChild( b );
}Dosn't actually insert "»" as the value, but the literal string "»"
Is there some type of translation of the entity that occurs here? Between the function call and execution? I even thought that because the call is in the BODY and the function is in the HEAD that maybe the entity is valuated differently, but after moving the function to the BODY I find this isn't the case.
I'm not really looking for a workaround or anything, just curious as to the nature of this behavior.
:confused: