I see what you mean now. Using createElement etc.
What I'm doing is taking my script in my document and trying to make it external. I'm not used to external scripting. So what I'd like to know is what would "window.document" reference to in the external script? Would it refer to the document of that's calling the external script?
Also, I used:
Code: Select all
ttDiv = document.createElement("div");
ttDiv.id = "MyDiv";
document.body.appendChild(ttDiv);
does this look right to you or would setAttribute be better then the id property?
Another question I have is: Say I have variable defined in a if statement in a function. Now where would that be accessible? I don't think that would be global, I'm assuming that it would only be available in that particular function. So how would I extent it's accessibility? I noticed that when I remove the "var" keyword from the line where I define the variable it makes it global, I think? Why when I remove the "var" keyword does it do that and why is there no error there is it because that it's no longer a variable but a reverence to an object or something?
Whew... Sorry for all the questions. But if you could answer as many of them as possible I'd very much appreciate it. I'm just a little bit stumped.
