View Full Version : another layer to layer question
dillieo
08-09-2002, 01:18 AM
K guys, another one for ya...
I'm trying to scroll down to an achor in a layer. I used to be able to do this with two different frames by calling:
parent.notesframe.location.hash = id;
where id is the name of the anchor.
How would I do this with layers. I tried
commlayer.location.hash = id. but I get the error comes back that commlayer.location is null or not an object. I was thinking of using scrollTo method, but I don't know how to get hte coordinates of the prenamed anchors. Any advice? I'll take either the IE or Netscape answer, I can piece the other accordingly.
Thanks in advance!
adios
08-09-2002, 01:27 AM
Someone should outlaw that word ('layer') in this context since it really doesn't mean anything; but, assuming you're referring to an element (HTML <div>, <span>), these are not window objects and can't be handled with window routines (scrolling, anchors). You'll need a DHTML solution, hard to suggest without seeing what else is happening.
dillieo
08-11-2002, 04:11 PM
I've got it setup as a couple <div>'s that contain two separate results from database queries. They are cross referenced, so that a few items in <div>A have a link to scroll down to an anchor point in <div>B. You think it would be possible to set a transparent gif or some kind of form element and do a getfocus() command to provide the same effect. Would using an iFrame to accomplish this have any advantages?
adios
08-12-2002, 01:10 AM
An <iframe> would definately solve your problem - iframes are window objects and support traditional browser scrolling/anchors. Otherwise, the technique I've generally used is embedding a <span> with an 'anchor' id in the container element (<generally a <div>) and using a dhtml scroller script to 'scroll' to it.
adios
08-12-2002, 03:14 AM
Ah, well...every day you learn something :o
<html>
<head>
<title>untitled</title>
<style type="text/css">
#box {
width: 80%;
height: 110px;
overflow: hidden;
font: 200 18px helvetica;
color: olive;
margin: 40px;
border: 3px gold double;
}
body {
text-align: center;
}
a {
font: 200 14px monospace;
color: darkgreen;
}
</style>
<script type="text/javascript" language="javascript">
function getElement(id) {
return document.getElementById ? document.getElementById(id) :
document.all ? document.all(id) : null;
}
function scrollToAnchor(scrollEl_id, anchorEl_id) {
var scrollEl = getElement(scrollEl_id);
var anchorEl = getElement(anchorEl_id);
if (scrollEl && anchorEl) scrollEl.scrollTop = anchorEl.offsetTop;
}
</script>
</head>
<body>
<div id="box">
<span id="section1">
SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1
SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1
SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1
SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1
SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1 SECTION 1</span><br>
<span id="section2">
SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2
SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2
SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2
SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2
SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2
SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2 SECTION 2</span><br>
<span id="section3">
SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3
SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3
SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3
SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3
SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3
SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3 SECTION 3</span>
</div>
<a href="" onclick="scrollToAnchor('box','section1');return false;">SECTION 1</a><br>
<a href="" onclick="scrollToAnchor('box','section2');return false;">SECTION 2</a><br>
<a href="" onclick="scrollToAnchor('box','section3');return false;">SECTION 3</a>
</body>
</html>
dillieo
08-12-2002, 02:54 PM
You are the man!!!! Thanks so much! I'll get that workin' in right away!
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.