PDA

View Full Version : Relatively positioning from a link???


tired&lonely
08-30-2002, 12:58 AM
Ok, I might have a new but much simpler approach to my problem, if I can word it correctly for you (newbie here)...

Is there any way one can relatively position something from an anchor in a webpage? For instance, if the anchor is such: <a name="DESC">Description</a>), can a Y-POSITION value be set based on this anchor?

adios
08-30-2002, 01:17 AM
Rough idea:

<html>
<head>
<title>untitled</title>
<script type="text/javascript" language="javascript">

function vert_align(align_id, with_id) {
var align_el = document.getElementById ? document.getElementById(align_id) :
document.all ? document.all(align_id) : null;
var with_el = document.getElementById ? document.getElementById(with_id) :
document.all ? document.all(with_id) : null;
if (align_el && with_el) align_el.style.top = String(with_el.offsetTop + 'px');
}

</script>
</head>
<body>
<a href="javascript:void vert_align('mover','test')">align it</a><br>
<div id="mover" style="position:absolute;font:bold 16px arial;color:red;">
------------&gt;</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<a id="test" name="DESC"></a>
<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah</pre>
</body>
</html>

tired&lonely
09-01-2002, 09:04 AM
adios, your ability to toss off javascript like it's child's-play is beyond amaaaaaaaazing!!! I tried out your "rough idea" alone as a test webpage and of course it works perfectly. But unfortunately, I'm not able to modify it to work for my application. If you have the time, could you take a look at this:

http://members.aol.com/thecddj/Test2.html

If you look at the source code, scroll way down approximately to the middle of this long code to the comment block (starting with "<!-- THE PROBLEM: -->") where I outline the problem and propose an idea I have for a possible solution (hopefully NOT misguided though) using this "rough idea" of yours to relatively position my progress bar from an anchor within a webpage. I'm not knowledgeable enough (or perhaps, smart enough) to know how to implement this idea, but maybe it'll be an easy starting off point for some you or some other javascript expert on this forum to help me out. If I ever get this problem resolved, I'll be TOTALLY ECSTATIC!!!!

Martin (at thecddj@aol.com)