Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #11770
| From | "Jukka K. Korpela" <jkorpela@cs.tut.fi> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: document.write within a form |
| Date | 2012-02-15 09:18 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <jhfm7i$14s$1@dont-email.me> (permalink) |
| References | <8d6567e4-a028-4c9f-83e1-5063099fe00e@og8g2000pbb.googlegroups.com> |
2012-02-15 8:29, cerr wrote:
> I would like to passalong two parameters as hidden fields within a
> form thus I did following:
> <script type="text/javascript">
> alert("screensize: "+screen.availHeight + "x" +
> screen.availWidth);
> dodcument.write("<input type=\"hidden\" name=\"height\" value=
> \""+screen.availHeight+"\"/>");
> dodcument.write("<input type=\"hidden\" name=\"width\" value=
> \""+screen.availWidth+"\"/>");
> </script>
> within the form but that doesn't seem to work, why not I'm wondering,
Well, you didn't lint your code, did you? Which object might "dodcument" be?
But the main point is that you shouldn't try to use document.write() for
such purposes. Instead, add elements to the document tree in a
structured manner. If you don't know how to do that, you shouldn't be
messing around with document modifications before you've read a
JavaScript tutorial.
Or maybe the main point is really that you are trying to do the wrong
thing, getting screen size and passing the information to a server.
Unless you are trying to collect statistics, it's difficult to see what
useful purpose it might serve (and not so difficult to guess what wrong
ideas one might try to implement that way).
--
Yucca, http://www.cs.tut.fi/~jkorpela/
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
document.write within a form cerr <ron.eggler@gmail.com> - 2012-02-14 22:29 -0800
Re: document.write within a form "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-02-15 09:18 +0200
Re: document.write within a form cerr <ron.eggler@gmail.com> - 2012-02-15 10:52 -0800
csiph-web