[whatwg] [WA1] The a element could be empty

That javascript shows how to actually do the insertion - but how do you
reference the point between the third and fourth paragraphs? For example,
how would you reference it from another document?

Possibly via some URI with a local xpath style anchor -
http://someplace.com/work/existing.html#xpath(/body/p[3])
If any element can have an id attribute, that would be sufficient - empty
<a> elements aren't strictly required to allow inbound links.



----- Original Message ----- 
From: "Jasper Bryant-Greene" <jasper@bryant-greene.name>
To: <whatwg at whatwg.org>
Sent: Saturday, September 03, 2005 8:17 PM
Subject: Re: [whatwg] [WA1] The a element could be empty


> S. Mike Dierken wrote:
> >>Yes, but it still shouldn't be empty, how can you link to part of a page
> >
> > that's nothing?
> > You mean 'why' rather than how? I suppose if you had a system that
allowed
> > your boss to tell you "add a paragraph of blurbiage after paragraph 3
and
> > before paragraph 4", how you you reference that point between existing
> > elements?
>
> Certainly not with an empty <a> element, that's for sure. In this HTML
> fragment:
>
> | <body>
> | <p>First paragraph...</p>
> | <p>Second paragraph...</p>
> | <p>Third paragraph...</p>
> | <p>Fourth paragraph...</p>
> | </body>
>
> Some JS like this:
>
> | var body = document.getElementsByTagName('body')[0];
> | var fourthParagraph = body.getElementsByTagName('p')[3];
> |
> | var newParagraph = document.createElement('p');
> | newParagraph.appendChild(document.createTextNode('New paragraph'));
> |
> | body.insertBefore(newParagraph, fourthParagraph);
>
> Would do exactly that.
>
> -- 
> Jasper Bryant-Greene
> Freelance web developer
> http://jasper.bryant-greene.name/
>
>

Received on Sunday, 4 September 2005 14:14:31 UTC