|
-
July 19th, 2005, 06:28 AM
#1
Scroll to Named Anchor in IFRAME
Hi,
I am working on a page that includes an Iframe. Inside this Iframe I dynamically assign named anchors.
Now, what I want to do is as follows: I want to use a SELECT menu to scroll to the named anchors in the Iframe.
However, the SELECT menu is not situated in the Iframe source page, but rather in the page containing the Iframe.
In other words; I've got a page called index.php that contains both the
coding for the SELECT menu:
Code:
<select name='menu' onchange='scroll2anchor();'>
and the iframe coding:
Code:
<IFRAME name="gerechten" src="lijst_gerechten_test.php"></IFRAME>
The option values in the SELECT menu coincide with the named anchors, and I am using them to determine to which named anchor needs to be scrolled. Thus, selecting option 4 would have to scroll to named anchor 4.
I tried to use a javascript function that contains:
Code:
function scroll2anchor(a) {
var lok;
lok = "#"+a;
document.gerechten.location.href=lok;
}
But rather than scrolling to the named anchor in the Iframe, it actually loads the entire page inside the Iframe.
Can anyone help me out with this issue? If you need more information just let me know.
Thx in advance!
With kind regards,
Oculas
-
July 19th, 2005, 06:45 AM
#2
Re: Scroll to Named Anchor in IFRAME
I already solved it.
I recoded the function as follows:
Code:
function scroll2anchor(a) {
var element = null;
element = document.getElementById("gerechten");
iframe_src = element.src;
var src_array=iframe_src.split("#");
document.getElementById("gerechten").src= src_array[0]+"#"+a;
}
This works like a charm, both in IE and Firefox 
Regards,
Oculas
Last edited by oculas; July 19th, 2005 at 07:06 AM.
-
July 19th, 2005, 11:22 AM
#3
Re: Scroll to Named Anchor in IFRAME
*9-11-01* Never Forget; Never Forgive; Never Relent!
"If we ever forget that we're one nation under God, then we will be a nation gone under." - Ronald Reagan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|