look at this code,
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
function change()
{
document.getElementById("myInput").type="text";
}
</script>
</head>
<body onload="setTimeout('change()',2000);">
<input type = "button" id="myInput">
</body>
</html>
now, my button becomes text box after 2 seconds.. Iam happy!
Why not the same happens when i try to do from the browser (i tested in IE6 & Chrome) using
javascript:document.getElementById("myInput").type="text"
different browsers behave in different way…
when i tried javascript:document.getElementById("myInput").value="myNewValue", IE6 changes the value, but chrome doesn’t..
Why is this “javascript:” behaving like this ?
Use:
I’m not sure why it behaves like that, I think that it is because setting a value returns the value, and returning a string results in a page displaying that string, like:
Will open a page with ‘test’., Using setAttribute() returns nothing.