On Tue, 24 Feb 2004 13:57:47 GMT, Ward <ki************@for.president.com>
wrote:
The topframe contains a listbox with trucknumbers (non sequential).
The mainframe contains a page, where each truck has a table with data.
In the topleft cell of each table I put a named link
<a name=$trucknumber>.
New webpages should target sections within documents using the id
attribute instead of using A elements as anchors. So, in place of:
<table>
<tr>
<td><a name="frag-identifier"></a>
...
you might use:
<table>
<tr id="frag-identifier">
<td>
...
I want to use an onChange event in the listbox to jump to the
corresponding anchor in the mainframe. The function below
doesn't work.
function jump(anker){
parent.frames['main'].href="#"+parent.frames['main'].links[anker].value;
}
any suggestions ?
1) Window objects, and therefore frames, do not have a href property.
2) ...nor do they have a links property.
3) Knowing what 'anker' is would be helpful.
The approach you have presented seems likely to fail in all browsers. Even
after correcting the l-value to use location, not href, it will still fail
in most browsers.
A simpler solution would be:
function changePage( linkList ) {
var fragment = linkList.options[ linkList.selectedValue ].value;
// Check that the option does contain a fragment identifier
// This allows for options such as "Choose section" which should
// have no destination
if( fragment ) parent.frames['main'].location = '#' + fragment;
}
...
<select onchange="changePage(this)">
<option value="">Choose section</option>
<option value="Section-1">Section 1</option>
<option value="Section-2">Section 2</option>
...
</select>
Mike
--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)