|
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
Can't for the life of me figure out how to get a hr into a js write.
http://blinkynet.net/humor/index.html I'd like a *scripted* <hr> just before the first line created by the fist little script do that it separates the quote of the day from the page intro above it. The reason I want it to be part of the script is so if scripts are disabled and the separator isn't needed, it's not rendered. (The nonscripted <hr> *after* the quote of the day will be all the separation I need between the intro and the list.) I've been able to make this work just fine with "<hr />" being the first element in the first document.write: document.write("<hr />" + "foo") But validation fails with a you-can't-use-a-<hr>-there error. So I look at W3Schools, which I think I've seen recommended here for tutorials -- I'm obviously new to js. ![]() Barely into the js tute, I see: <q> A JavaScript statement like this: document.write("<h1>" + name + "</h1>") can write a variable text into an HTML page </q> Now if they can get a <h1> in there, why can't I get a <hr> in, using the same method? Yes, I tried it with and without closing tags. Validator won't have anything do do with it. Is there a *simple* way to do that I want? No, I'm not going to do twelve lines of code for one hr. ![]() -- Blinky RLU 297263 Killing all posts from Google Groups The Usenet Improvement Project: http://improve-usenet.org <----------- New Site Aug 28 |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
Blinky the Shark wrote:
> Can't for the life of me figure out how to get a hr into a js write. > > http://blinkynet.net/humor/index.html > > I'd like a *scripted* <hr> just before the first line created by the > fist little script do that it separates the quote of the day from the FIRST little script SO that it separates... Grrrrrr. > page intro above it. The reason I want it to be part of the script is > so if scripts are disabled and the separator isn't needed, it's not > rendered. (The nonscripted <hr> *after* the quote of the day will be > all the separation I need between the intro and the list.) > > I've been able to make this work just fine with "<hr />" being the first > element in the first document.write: > > document.write("<hr />" + "foo") > > But validation fails with a you-can't-use-a-<hr>-there error. > > So I look at W3Schools, which I think I've seen recommended here for > tutorials -- I'm obviously new to js. ![]() > > Barely into the js tute, I see: > ><q> > > A JavaScript statement like this: document.write("<h1>" + name + > "</h1>") can write a variable text into an HTML page > ></q> > > Now if they can get a <h1> in there, why can't I get a <hr> in, using the > same method? Yes, I tried it with and without closing tags. Validator > won't have anything do do with it. > > Is there a *simple* way to do that I want? No, I'm not going to do > twelve lines of code for one hr. ![]() > > -- Blinky RLU 297263 Killing all posts from Google Groups The Usenet Improvement Project: http://improve-usenet.org <----------- New Site Aug 28 |
|
|
|
#3 (permalink) |
|
Messages: n/a
Hébergeur: |
On 2007-09-11, Blinky the Shark <no.spam@box.invalid> wrote:
> Can't for the life of me figure out how to get a hr into a js write. > > http://blinkynet.net/humor/index.html > > I'd like a *scripted* <hr> just before the first line created by the document.write() won't work? > But validation fails with a you-can't-use-a-<hr>-there error. So this would be an HTML issue, not a js issue. To which standard are you writing? HTML 4 Transitional? Strict? XHTML Transitional? Strict? -- Steve Sobol, Victorville, California PGP:0xE3AE35ED "Drench yourself in words unspoken / Live your life with arms wide open Today is where your book begins / The rest is still unwritten" - Natasha Beddingfield |
|
|
|
#4 (permalink) |
|
Messages: n/a
Hébergeur: |
Steve Sobol wrote:
> On 2007-09-11, Blinky the Shark <no.spam@box.invalid> wrote: >> Can't for the life of me figure out how to get a hr into a js write. >> >> http://blinkynet.net/humor/index.html >> >> I'd like a *scripted* <hr> just before the first line created by the > > document.write() won't work? As I said, it works, but it won't validate. >> But validation fails with a you-can't-use-a-<hr>-there error. > > So this would be an HTML issue, not a js issue. To which standard are you Call it what you'd like. As I stated, the problem is that I can't - via js - figure out how to get something to validate that validates when I do the same thing without the script. Putting an <hr> in the body (correct - not within a <p> or <div> validates, but it won't if js places it there. > writing? HTML 4 Transitional? Strict? XHTML Transitional? Strict? That's in my doctype. That kind of thing is why I gave the link. ![]() I've been bad: XHTML because when I did a total rewrite of the site a couple hears ago I thought that was The Coming Thing and wanted to not go backward; but served as HTML because then I learned that browser support was supposedly iffy for XHTML. -- Blinky RLU 297263 Killing all posts from Google Groups The Usenet Improvement Project: http://improve-usenet.org <----------- New Site Aug 28 |
|
|
|
#5 (permalink) |
|
Messages: n/a
Hébergeur: |
Blinky the Shark wrote:
> Steve Sobol wrote: >> On 2007-09-11, Blinky the Shark <no.spam@box.invalid> wrote: >>> Can't for the life of me figure out how to get a hr into a js write. >>> >>> http://blinkynet.net/humor/index.html >>> >>> I'd like a *scripted* <hr> just before the first line created by the >> >> document.write() won't work? > > As I said, it works, but it won't validate. > >>> But validation fails with a you-can't-use-a-<hr>-there error. >> >> So this would be an HTML issue, not a js issue. To which standard are you > > Call it what you'd like. As I stated, the problem is that I can't - via > js - figure out how to get something to validate that validates when I > do the same thing without the script. Putting an <hr> in the body > (correct - not within a <p> or <div> validates, but it won't if js > places it there. > >> writing? HTML 4 Transitional? Strict? XHTML Transitional? Strict? > > That's in my doctype. That kind of thing is why I gave the link. ![]() > > I've been bad: XHTML because when I did a total rewrite of the site a > couple hears ago I thought that was The Coming Thing and wanted to not > go backward; but served as HTML because then I learned that browser > support was supposedly iffy for XHTML. Here's test copy of that page with what I'm *trying* to do. See commented div. When that <hr> is generated by a js document.write, it won't validate. If I just put a <hr> in the same place in the page (in that div, or just in the body without that div existing, the <hr> page validates. http://blinkynet.net/humor/index2.html Sorry I didn't link *this* before. Again, I want the <hr> to be js-generated so that it's not there when js is disabled -- in that case it's not needed because the whole quote-of-the-day section isn't rendered. -- Blinky RLU 297263 Killing all posts from Google Groups The Usenet Improvement Project: http://improve-usenet.org <----------- New Site Aug 28 |
|
|
|
#6 (permalink) |
|
Messages: n/a
Hébergeur: |
Blinky the Shark wrote:
> document.write("<hr />" + "foo") > > But validation fails with a you-can't-use-a-<hr>-there error. Try: document.write("<hr \/>" + "foo"); When using document.write() combined with XHTML, you need to escape the closing slashes in end tags otherwise it won't validate. It should still /work/ okay without it though. -- Dylan Parry http://electricfreedom.org | http://webpageworkshop.co.uk The opinions stated above are not necessarily representative of those of my cats. All opinions expressed are entirely your own. |
|
|
|
#7 (permalink) |
|
Messages: n/a
Hébergeur: |
Dylan Parry wrote:
> Blinky the Shark wrote: > >> document.write("<hr />" + "foo") >> >> But validation fails with a you-can't-use-a-<hr>-there error. > > Try: > > document.write("<hr \/>" + "foo"); > > When using document.write() combined with XHTML, you need to escape the > closing slashes in end tags otherwise it won't validate. It should still > /work/ okay without it though. Nope. As before: works but won't validate. Here, with your idea: http://blinkynet.net/humor/index2.html Try it. -- Blinky RLU 297263 Killing all posts from Google Groups The Usenet Improvement Project: http://improve-usenet.org <----------- New Site Aug 28 |
|
|
|
#8 (permalink) |
|
Messages: n/a
Hébergeur: |
Blinky the Shark wrote:
> Can't for the life of me figure out how to get a hr into a js write. > > http://blinkynet.net/humor/index.html > > I'd like a *scripted* <hr> just before the first line created by the > fist little script do that it separates the quote of the day from the > page intro above it. The reason I want it to be part of the script is > so if scripts are disabled and the separator isn't needed, it's not > rendered. (The nonscripted <hr> *after* the quote of the day will be > all the separation I need between the intro and the list.) > > I've been able to make this work just fine with "<hr />" being the first > element in the first document.write: > > document.write("<hr />" + "foo") > > But validation fails with a you-can't-use-a-<hr>-there error. > > So I look at W3Schools, which I think I've seen recommended here for > tutorials -- I'm obviously new to js. ![]() > > Barely into the js tute, I see: > > <q> > > A JavaScript statement like this: document.write("<h1>" + name + > "</h1>") can write a variable text into an HTML page > > </q> > > Now if they can get a <h1> in there, why can't I get a <hr> in, using the > same method? Yes, I tried it with and without closing tags. Validator > won't have anything do do with it. > > Is there a *simple* way to do that I want? No, I'm not going to do > twelve lines of code for one hr. ![]() > > Are you sure it isn't just the validator not understanding js? Most don't, and try to parse the js as html somehow. It doesn't mean the page is invalid - just that the validator doesn't understand it. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
![]() |
| Outils de la discussion | |
|
|