Javascript VML for IE: Object coordinate are not what they should be(not matching the input)


  I am trying to develop a project that use VML to create basically a flow chart with, though I have a small problem. The width and height of the object are correct but as for the position it's twice what I request. For instance a "rect" of 100x100 in size, position at 0,0 will be at the right place but if I put for instance another "rect" at 100,100 they will be in fact at 200,200. Anyway reason why and how I can overcome this problem??

Thank you
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

declare a css definition for the elements in question and set their position to absolute.
 <v:shape type="#myFirstRectangle"
   style='position: absolute; left:0; top: 0; width: 100px; height: 100px'>...</v:shape>
 <v:shape type="#mySecondRectangle"
   style='position: absolute; left:0; top: 0; width: 100px; height: 100px'>...</v:shape>
DogofwarsAuthor Commented:
The group object is absolute but not the child one that are relative. They are inserted dynamically as for the CSS would it really made any difference, what would I need to put in the CSS so it make a difference!?
Basically you need to do something similar to my example below. I am using HTML but the same rules apply. I don't know how experienced you are with css, but when you use absolute positioning, the reference point of the element that is being positioned "absolutely", is its parent element. To clarify, on my example, the "parent" of "container" is <body>. So when I say "top:0, left:5px", then the browser will first find  the top-left corner of the <body> box/area and use it as its reference point. Then position "container" 0px from the top of that corner and then 5px over. Similarly, you will find that my "child1" and "child2" elements are positioned absolute, but their reference point is not <body>, but rather <div id="container">. That's why, if you notice, the child1 and child 2 appear one above the other since both have left:1em;. The only thing that I changed was the top position and I did it so that child2 appears above child1. If I had set them both to top: 1em; left:1em; they would literally overlap.
If this is still not clear, then perhaps the following link might help you understand positioning better (middle of page):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="">
<style type="text/css">
#container{position:absolute; top:3em; left:5em;background-color:lightgrey;}
	<div id="container">
		<div id="child1">b</div>
		<div id="child2">c</div>

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

DogofwarsAuthor Commented:
That work with standard DHTML but it does not seam to work with VML
I find that hard to believe. CSS is independent of HTML. The rules/definitions apply to "markup elements" (in general), not HTML elements. Most likely you are not providing the correct element references.
In addition to "position:absolute;" you could try adding "display:inline;" to the elements in question.
DogofwarsAuthor Commented:
With the example below you might understand better. All the VML object except the standard object like input, textarea etc.. are  not at the right place(position) but they have the right size!? If you set them at 100,100 they will be at 200,200 and if you set them at 200,200 they will be at 400,400 like there is a multiplier of 2. If you change the " v:group" tag to div the whole thing goes at the right place except the VML "v:rect" tag that is still using a multiplier of 2 for the position. I just don't know what to set to remove this multiplier so it the object get all positioned at the right place.
var vm = document.createElement("v:group");
vm.setAttribute("id", Name + "_Group"); = "absolute"; = W + "px"; = H + "px"; = X + "px"; = Y + "px"; = 1
vm.setAttribute("coordsize", W + " " + H);
o = document.createElement("v:rect");
o.setAttribute("id",Name) = "absolute"; = X + "px"; = Y + "px"; = W  + "px"; = H + "px"; = 2
o.setAttribute("fillcolor", 'white');
o = null
o = document.createElement("input");
o.setAttribute("id",Name + "_TextInput") = "absolute"; = X + 10 + "px"; = Y + 5 + "px"; = W - (title.length * 8) + "px"; = 30 + "px"; = 3
o = null
vm = null

Open in new window

DogofwarsAuthor Commented:
By the way I had this code in multiple wrapper function but I made this simplier so you can understand you won't be able to execute de code, you will need to modifie it a bit.
DogofwarsAuthor Commented:
The fault was in the wrapper itself, it injected twice the value I change that and it display correctly now, I guess I tried to make it too complicate :)
DogofwarsAuthor Commented:
It's not really VML but it does the same job.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.