|
Javascript and document.write
#288178
09/04/09 15:59
09/04/09 15:59
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
I want to use a document.write command in javascript to write a line at the very beginning of the html file in which it is writing. I know how to use document.write(""); but I don't know how to tell the javascript to go to the very beginning of the html file. Can someone help me with this?
- aka Manslayer101
|
|
|
Re: Javascript and document.write
[Re: mpdeveloper_B]
#288182
09/04/09 16:04
09/04/09 16:04
|
Joined: Aug 2003
Posts: 7,439 Red Dwarf
Michael_Schwarz
Senior Expert
|
Senior Expert
Joined: Aug 2003
Posts: 7,439
Red Dwarf
|
body.innerHTML = "hi there" + body.innerHTML;
should do the trick
"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
|
|
|
Re: Javascript and document.write
[Re: Michael_Schwarz]
#288185
09/04/09 16:21
09/04/09 16:21
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
I mean at the absolute beginning of the file, not the body. Before all the headers and everything. Line numero uno.
- aka Manslayer101
|
|
|
Re: Javascript and document.write
[Re: mpdeveloper_B]
#288187
09/04/09 16:37
09/04/09 16:37
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
I have to put this line at the beginning of the html file by using javascript, can it be done?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
Last edited by mpdeveloper_B; 09/04/09 16:38.
- aka Manslayer101
|
|
|
Re: Javascript and document.write
[Re: mpdeveloper_B]
#288189
09/04/09 16:53
09/04/09 16:53
|
Joined: Aug 2003
Posts: 7,439 Red Dwarf
Michael_Schwarz
Senior Expert
|
Senior Expert
Joined: Aug 2003
Posts: 7,439
Red Dwarf
|
html.innerHTML = "hi there" + html.innerHTML;
"should" work, but I'm not really sure.
"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
|
|
|
Re: Javascript and document.write
[Re: Michael_Schwarz]
#288192
09/04/09 17:02
09/04/09 17:02
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
no dice. I'm curious about this...is there a way to change the doctype in javascript...
- aka Manslayer101
|
|
|
Re: Javascript and document.write
[Re: Joey]
#288195
09/04/09 17:11
09/04/09 17:11
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
well, I guess that solves that I'll have to change the doctype manually then. I was asking because the website software that we use for yahoo doesn't set doctypes, which can cause some problems, and if you change the files out of the program and open them back up it deletes any changes to the beginning of the file so all doctypes are removed... Oh well, guess that means anytime we update I'll have to change the doctype. Hopefully we won't have to update alot.
- aka Manslayer101
|
|
|
Re: Javascript and document.write
[Re: mpdeveloper_B]
#288245
09/04/09 23:07
09/04/09 23:07
|
Joined: Jan 2008
Posts: 1,580
Blade280891
Serious User
|
Serious User
Joined: Jan 2008
Posts: 1,580
|
erm surely
<script> document.write(""); </script> <!doctype....
If that doesn't work and you need a solution i will be more than happy to create one for you
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
|