Connecting Tech Pros Worldwide Forums | Help | Site Map

Javascript graphics

Jakanapes
Guest
 
Posts: n/a
#1: May 17 '06
I've been trying out David Betz's sample chapter on doing graphics with
javascript
http://www.davidbetz.net/graphics/

But I can't get the horizontal line to draw. There's no errors in
Firefox's javascript console so I'm not sure what I'm doing wrong. I'm
not even close to javascript expert, though...


<html>
<head>
<title>Horizontal Line Test</title>


<script language="javascript" type="text/javascript">
function DrawHorizontalLine(x, y, l, c, parentObj) {
var longPixel = document.createElement('div');
longPixel.className = 'Ink';

longPixel.style.width = 1 + 'px';

longPixel.style.left = x + 'px';
longPixel.style.top = y + 'px';

longPixel.style.borderTopColor = c;

parentObj.appendChild(longPixel);
}
</script>
</head>
<body>
<div id="dynamicAttacher"></div>
<script language="javascript" type="text/javascript">
var dynamicAttacherObj = document.getElementById('dynamicAttacher');
DrawHorizontalLine( 100, 100, 200, "#000000, dynamicAttacherObj );
</script>
</body>
</html>


Martin Honnen
Guest
 
Posts: n/a
#2: May 17 '06

re: Javascript graphics




Jakanapes wrote:

[color=blue]
> But I can't get the horizontal line to draw. There's no errors in
> Firefox's javascript console so I'm not sure what I'm doing wrong.[/color]

[color=blue]
> DrawHorizontalLine( 100, 100, 200, "#000000, dynamicAttacherObj );[/color]
^^^^
That should surely give a syntax error, I guess you want
DrawHorizontalLine( 100, 100, 200, "#000000", dynamicAttacherObj );

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jakanapes
Guest
 
Posts: n/a
#3: May 17 '06

re: Javascript graphics


yeah, I saw that after I posted. Fixed it and still don't get a line.

I tried the canvas example lower on the page and I get a canvas border,
but still no horizontal line...

still researching.

Closed Thread


Similar JavaScript / Ajax / DHTML bytes