473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

anchors

Hi,

I have a topframe and a mainframe.

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>.
Tables are generated using php.

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 ?
thx

Ward
Jul 20 '05 #1
8 1615
Ivo
"Ward" <ki************@for.president.com> wrote in message
news:Xn**********************************@195.130. 132.70...
<snip>
function jump(anker){
parent.frames['main'].href="#"+parent.frames['main'].links[anker].value;
}
Have you also tried the variant with "location." just before "href." ?
HTH
Ivo
any suggestions ?
thx

Ward

Jul 20 '05 #2
Lee
Ward said:

Hi,

I have a topframe and a mainframe.

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>.
Tables are generated using php.

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;


parent.frames['main'].location.hash="#"+truckNumber;

Jul 20 '05 #3
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)
Jul 20 '05 #4
Michael Winter <M.******@blueyonder.co.invalid> wrote in
news:op**************@news-text.blueyonder.co.uk:
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].valu
e; }

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


If you change selectedValue to selectedIndex your example does indeed
work.

thx for your help

Ward
Jul 20 '05 #5
On Tue, 24 Feb 2004 21:45:02 GMT, Ward Germonpé
<ki**********@forpresident.com> wrote:
Michael Winter <M.******@blueyonder.co.invalid> wrote in
news:op**************@news-text.blueyonder.co.uk:
[snip]
function changePage( linkList ) {
var fragment = linkList.options[ linkList.selectedValue ].value;


[snip]
If you change selectedValue to selectedIndex your example does indeed
work.


Sorry. :) Lapse in concentration.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #6
Michael Winter <M.******@blueyonder.co.invalid> wrote in
news:op**************@news-text.blueyonder.co.uk:
On Tue, 24 Feb 2004 21:45:02 GMT, Ward Germonpé
<ki**********@forpresident.com> wrote:
Michael Winter <M.******@blueyonder.co.invalid> wrote in
news:op**************@news-text.blueyonder.co.uk:


[snip]
function changePage( linkList ) {
var fragment = linkList.options[ linkList.selectedValue ].value;


[snip]
If you change selectedValue to selectedIndex your example does indeed
work.


Sorry. :) Lapse in concentration.

Mike


I'm not quite there yet...

I had to change the code as follows to prevent the topframe from loading
into the mainframe.

if (fragment) parent.frames['main'].location = parent.frames
['main'].location + '#' + fragment;

Now it works, but only once.

There are no errors in the javascript console.
thx

Ward
Jul 20 '05 #7
On Wed, 25 Feb 2004 10:18:27 GMT, Ward <ki************@for.president.com>
wrote:
Michael Winter <M.******@blueyonder.co.invalid> wrote in
news:op**************@news-text.blueyonder.co.uk:
On Tue, 24 Feb 2004 21:45:02 GMT, Ward Germonp
<ki**********@forpresident.com> wrote:
[snip]
If you change selectedValue to selectedIndex your example does indeed
work.


Sorry. :) Lapse in concentration.


I'm not quite there yet...

I had to change the code as follows to prevent the topframe from loading
into the mainframe.

if (fragment) parent.frames['main'].location = parent.frames
['main'].location + '#' + fragment;

Now it works, but only once.

There are no errors in the javascript console.


That is because a second usage will append, not replace, the first
fragment identifier. That is,

index.html -> index.html#Section-1 -> index.html#Section-1#Section-2

Lee's use of Location.hash should fix this:

if (fragment) parent.frames['main'].location.hash = '#' +
fragment;

Hopefully, that should be it.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #8
Michael Winter <M.******@blueyonder.co.invalid> wrote in
news:op**************@news-text.blueyonder.co.uk:
On Wed, 25 Feb 2004 10:18:27 GMT, Ward
<ki************@for.president.com> wrote:
Michael Winter <M.******@blueyonder.co.invalid> wrote in
news:op**************@news-text.blueyonder.co.uk:
On Tue, 24 Feb 2004 21:45:02 GMT, Ward Germonp
<ki**********@forpresident.com> wrote:
[snip]
If you change selectedValue to selectedIndex your example does
indeed work.

Sorry. :) Lapse in concentration.


I'm not quite there yet...

I had to change the code as follows to prevent the topframe from
loading into the mainframe.

if (fragment) parent.frames['main'].location = parent.frames
['main'].location + '#' + fragment;

Now it works, but only once.

There are no errors in the javascript console.


That is because a second usage will append, not replace, the first
fragment identifier. That is,

index.html -> index.html#Section-1 ->
index.html#Section-1#Section-2

Lee's use of Location.hash should fix this:

if (fragment) parent.frames['main'].location.hash = '#' +
fragment;

Hopefully, that should be it.

Mike


It works !

thx a lot

Ward
Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ben Wilson | last post by:
To anyone who can help me, you have my thanks in advance. I am implementing a "301 Moved Permanently" redirect in my website due to a change of our domain names. Unfortunately, I am having a...
1
by: Peter Jakobi | last post by:
Hello, I want to place two lines relative to another. The problem is, that these two lines are in different groups. Is there an possibility to set the x and y values of the second line with...
2
by: mlv2312 | last post by:
Hi, I have experienced problems when dealing with nested anchors. I implemented some code to perform highlighting and specific anchors are used for the searched words. The problem is when the...
1
by: mlv2312 | last post by:
Hi, I have experienced problems when dealing with nested anchors. I implemented some code to perform highlighting and specific anchors are used for the searched words. The problem is when the...
2
by: learner | last post by:
Hi, A document has many Anchors. I want to take a particular action only if some particular anchors are clicked. I mean if some anchors are clicked, i want an alert box to pop up with ok and...
21
by: adrian suri | last post by:
Hi just started to experement with styleshhets, and have defined hover a:hover { Color : red; Text-decoration : none; Border-top-width : medium; Border-right-width : medium;
12
by: Rich | last post by:
Strangely, on-page anchors will work on MSIE, but not on Netscape7.2 or Firefox1.5. All anchors are numbers e.g. <a href="#21">TOPIC</a> supposed to connect down to <a name="#21>beginning of...
17
by: Crimperman | last post by:
Hi, need some advice on URIs In a dynamic page (perl driven) we list a number of items presented in an hierarchical tree structure. Within that page is a form which allows you to search for...
1
by: Alec MacLean | last post by:
Hi. I'm using VS2005 Pro to work on a website project for my company. The site has several navigation elements, all based on the standard VS2005 navigation components. I have high-level...
3
by: windandwaves | last post by:
does it matter if I write var anchors = document.getElementsByTagName("A"); or var anchors = document.getElementsByTagName("a"); Or is there a better way to catch both <a hrefs and <A...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.