Write Javascript Variable On Html Body
Solution 1:
Once the document is loaded, you can't use document.write
without overwriting everything. You will need to manipulate the DOM, e.g. document.body.innerText=variablejs;
. But I'd recommend
var d = document.createElement("div");
d.appendChild(document.createTextNode(variablejs));
document.body.appendChild(d);
Solution 2:
You're assigning value to variablejs in the callback function you're passing to geocoder.geocode(). This means that you're trying to access and write it before the callback has been called and therefore you will not see any value set yet.
Debugging with Firebug or similar will help in these cases.
Also you can't use docuemnt.write like that after the document has been loaded, you'll need to do some DOM-manipulation instead.
Post a Comment for "Write Javascript Variable On Html Body"