Jump to content

Is a newobject() a HTML document element (child)?


lanmind

Recommended Posts

Hello everybody, please bear with me my enter key has stopped working. On my page here: http://www.dockhawk.com/ I'm trying to access a object created by one script in the <head> section of the HTML using another external javascript. The object is "variablecoin" and I want to change it's "worth" property. In the external js I've been trying many different HTML DOM access methods to no avail. I've been assuming the variablecoin object is an element of the HTML document but now I'm having doubts. Is it possible to access this var with an external script? Please see line 45 in the extenal js: http://www.dockhawk.com/javascript.js. Thank you, I hate my keyboard, lol : 0

Link to comment
Share on other sites

First, make sure you're using a debugger to check for errors. Some links here:http://w3schools.invisionzone.com/index.ph...st&p=101127You have this code:

						var xmlDoc = request.responseXML;						var token = xmlDoc.documentElement.getElementsByTagName("coin");						var coin = token[0].getAttribute("newcoin");						document.documentElement.firstChild.worth = coin;

Are you sure that coin is a valid value, have you alerted it to see what it is?When you create a variable in Javascript it doesn't go into the DOM, it's just in memory. Since the variablecoin variable is global, then you can just access it by name.variablecoin.worth = coin;

Link to comment
Share on other sites

First, make sure you're using a debugger to check for errors. Some links here:http://w3schools.invisionzone.com/index.ph...st&p=101127You have this code:
						var xmlDoc = request.responseXML;						var token = xmlDoc.documentElement.getElementsByTagName("coin");						var coin = token[0].getAttribute("newcoin");						document.documentElement.firstChild.worth = coin;

Are you sure that coin is a valid value, have you alerted it to see what it is?When you create a variable in Javascript it doesn't go into the DOM, it's just in memory. Since the variablecoin variable is global, then you can just access it by name.variablecoin.worth = coin;

Thank you,I didn't think that it stored it in memory, I just kept thinking the document, the document, the...you get the idea. variablecoin.worth = coin; worked. Thanks again justsomeguy.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...