PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.www.webmaster > js write a <hr>
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
js write a <hr>

Réponse
 
LinkBack Outils de la discussion
Vieux 11/09/2007, 05h52   #1 (permalink)
Blinky the Shark
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut js write a <hr>

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
  Réponse avec citation
Vieux 11/09/2007, 05h55   #2 (permalink)
Blinky the Shark
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: js write a <hr>

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
  Réponse avec citation
Vieux 11/09/2007, 06h12   #3 (permalink)
Steve Sobol
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: js write a <hr>

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

  Réponse avec citation
Vieux 11/09/2007, 09h46   #4 (permalink)
Blinky the Shark
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: js write a <hr>

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
  Réponse avec citation
Vieux 11/09/2007, 10h11   #5 (permalink)
Blinky the Shark
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: js write a <hr>

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
  Réponse avec citation
Vieux 11/09/2007, 10h35   #6 (permalink)
Dylan Parry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: js write a <hr>

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.
  Réponse avec citation
Vieux 11/09/2007, 11h13   #7 (permalink)
Blinky the Shark
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: js write a <hr>

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
  Réponse avec citation
Vieux 11/09/2007, 12h00   #8 (permalink)
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: js write a <hr>

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
==================
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h21.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,17348 seconds with 16 queries