W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2009

[whatwg] <a onlyreplace>

From: Markus Ernst <derernst@gmx.ch>
Date: Sat, 17 Oct 2009 00:08:20 +0200
Message-ID: <4AD8EED4.7060502@gmx.ch>
Tab Atkins Jr. schrieb:
[...]

>> The body of page1.html could look like:
>>
>> <div id="pageHeader">Recipies for vegetarians</div>
>> <div id="content">
>>  <h1>Lovely broccoli</h1>
>>  <p>Take the broccoli and do the following:</p>
>>  ...
>> </div>
>> <ul id="navigation">
>>  <li><span>Broccoli</span></li>
>>  <li><a href="page2.html" onlyreplace="content">Leak</a></li>
>> </ul>
>>
>> The body of page2.html:
>>
>> <div id="pageHeader">Recipies for meat eaters</div>
>> <div id="content">
>>  <h1>Lovely leak</h1>
>>  <p>Take the leak and do the following:</p>
>>  ...
>> </div>
>> <ul id="navigation">
>>  <li><a href="page1.html" onlyreplace="content">Broccoli</a></li>
>>  <li><span>Leak</span></li>
>> </ul>

[...]

> (Also, in your examples you probably want @onlyreplace="content
> navigation", since your nav is changing from page to page as well.

Indeed. Or, maybe I'd do it slightly differently, somehow like:

<ul id="navigation">
   <li><a href="page1.html" onlyreplace="content" class="thisPage"
     onClick="resetNavigation(this)">Broccoli</a></li>
   <li><a href="page2.html" onlyreplace="content"
     onClick="resetNavigation(this)">Leak</a></li>
</ul>

The resetNavigation() function then takes the class attribute from the 
old link and adds it to the clicked one. So the navigation can be 
static, and though its appearance remains consistent, whether page2.html 
is completely loaded, or only the parts defined in @onlyreplace.
Received on Friday, 16 October 2009 15:08:20 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:18 UTC