Mark Preston wrote:
<snip>
Quote:
4. The reference on the address tags should, I know, be of the form
"href='javascript:;'" to prevent page reloads when clicking on the
menu option since I have an "onLoad" event to set up the basic page.
No problem here - I've made pages like this loads of times. |
Absolute rubbish. This group strongly and repeatedly discourages the use
of javascript pseudo protocol HREFs, partly because they offer no
facility for clean degradation (or meaningful actions without javascript
being enabled) and partly because they directly cause problems with some
browser and OS combinations:-
<URL:
http://jibbering.com/faq/#FAQ4_24 >
And that particular formulation of a javascript pseudo protocol HREF -
"javascript
:;" - can be demonstrated to directly produce internally
suppressed syntax errors on IE 4 & 5 (it probably produces them on later
versions but the facility for the demonstration was removed).
"javascript
: void 0;" would be better as it will not represent a syntax
error (but preferably don't use javascript HREFs at all, ever).
Quote:
5. Now comes the fun bit... I want the pages to be fully accessible to
anyone at all (which is why the menu is text rather than images in the
first place). That has to include people who do not have
JavaScript-enabled browsers. |
You might consider that to be fully accessible it would be necessary to
facilitate keyboard navigation, and apparently not all javascript
capable/enabled browsers trigger onclick events when a currently focused
link is triggered via the keyboard (at least some older ones don't).
Doubling-up with a keydown/press event might be advisable (with
appropriate handling for the browsers that will trigger onclick in
addition to key events).
<snip>
Quote:
Now - the question is, how can I use anchor points (of the form
"href='#anchorname'" and yet still prevent page-reloads when the
menu option is selected? I know that some browsers will not do
page reloads anyway, but I need to be sure that none will. Any
ideas? |
Placing a fragment identifier in the HREF is the most sensible thing to
do. It does not need to conflict with the javascript in the onclick
handler because the onclick handler is allowed to prevent the navigation
using the HREF by cancelling the click event, usually be returning false
from the handler (possibly with additional W3C DOM and IE specific
default action cancelling code).
See:-
<URL:
http://www.litotes.demon.co.uk/js_info/pop_ups.html >
- for an example resembling what you are describing (note: the first
link will re-load the page with the script disabled and so can be used
to simulate interaction without javascript).
Richard.