Forum Moderators: open
When I remove the doctype the code functions as it should, but when I have the doctype in there it functions incorrectly.
the code that I am using is from
[mattkruse.com...]
it does what i want, but I can't use the doctype that i need to use for it. any thoughts?
I just use the first part of that
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
That technically is not a valid DOCTYPE.
Note, I have no problem using that library with the full DOCTYPE. Can you post your entire HTML code? Here's what I'm using:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled</title>
<script type="text/javascript" src="AnchorPosition.js"></script>
<script type="text/javascript">
<!--
function test(name) {
var c = getAnchorPosition(name);
alert("X = "+c.x+" , Y = "+c.y);
}
//-->
</script>
</head>
<body>
<div id="container">
<br><br><br>
<a href="#" name="test1" id="test1">Test Anchor</a>
<br>
<a href="#" onclick="test('test1');return false;">Test</a>
</div>
</body>
</html>
' This is the HTML 4.01 Transitional DTD, which includes
presentation attributes and elements that W3C expects to phase out
as support for style sheets matures. Authors should use the Strict
DTD when possible, but may use the Transitional DTD when support
for presentation attribute and elements is required.
HTML 4 includes mechanisms for style sheets, scripting,
embedding objects, improved support for right to left and mixed
direction text, and enhancements to forms for improved
accessibility for people with disabilities.
Draft: $Date: 1999/12/24 23:37:48 $
....'
Note, I have no problem using that library with the full DOCTYPE. Can you post your entire HTML code? Here's what I'm using:
Yea that works, but I don't want to just get the coords, I also want to mvoe the div, with what you posted there you've removed the part that actually moves the div which is what i need the code for.
as far as posting it, it's far to long to post here...
My basic goal here is to make it so that when you click a link an absolutely positioned div is placed ontop of the link with the contianed text going down from that point
Added: similar to the way a dhtml menu works.
Yea that works, but I don't want to just get the coords, I also want to mvoe the div, with what you posted there you've removed the part that actually moves the div which is what i need the code for.
You did not specify that in your original post. The library from the website you posted says specifically:
This library has one (not-so-simple) purpose: to get the coordinates of an anchor tag (<A>) on the page.
You should be more specific about what you're looking for when you post.
as far as posting it, it's far to long to post here...
Well, it's hard to help you without understanding what it is you're trying to do. Sorry.
Here's an updated version that works.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled</title>
<script type="text/javascript" src="AnchorPosition.js"></script>
<script type="text/javascript">
<!--
function test(name)
{
var c = getAnchorPosition(name);
alert("X = "+c.x+" , Y = "+c.y);
if (document.getElementById)
{
var o = document.getElementById("testdiv");
if (o.style)
{
o.style.left = c.x + "px";
o.style.top = c.y + "px";
}
}
}
//-->
</script>
</head>
<body>
<div id="container">
<br><br><br>
<a href="#" name="test1" id="test1">Test Anchor</a>
<br>
<a href="#" onclick="test('test1');return false;">Test</a>
<br><br><br><br>
<DIV ID="testdiv" STYLE="position:absolute;width:50px;height:50px;left:20px;top:1000px;background-color:yellow;">asdf</DIV>
</div>
</body>
</html>
added -
Well, it's hard to help you without understanding what it is you're trying to do. Sorry.