Position Floating Div respect to top&left of window document

I am trying to make a cross-browser floating div that "floats" on top of the window, with absolute position of  left-150px top-200px.  I got it working in Firefox with the following code:

var rng=document.createRange();  
rng.selectNode(document.body);  
document.body.appendChild(rng.createContextualFragment(myDiv));

where myDiv is set to have absolute position style that i need:

style="position:absolute;top:200px;left:150px;"

I can't get this to work on IE.  Anyone know the IE version of the code that I have above for Firefox?  Basically, appending it to the body and setting the position to some absolute position(may have to set the z-index as well).  Any suggestions/help will be greatly appreciated.

Thank you.  
mxyztplk333Asked:
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.

LakioCommented:
Send a screenshot of it in Firefox.
0
scrathcyboyCommented:
absolute positioning tends to give cross browser problems, each browser interprets the starting point for the absolute somewhat differently, depending on the elements in the table.  Try both IE6 and 7, see what difference there is.  If the problem is just in IE6 (which it usually is) I wouldn't worry too much about it.  Also test on the MAC browsers for full X-browser compat.
0
mxyztplk333Author Commented:
Thank you for your replies.  Basically, it's just a floating div with one Flash object&embed tags.  I know how to attach this Div to the document body in Firefox, but I don't know how to manipulate the DOM in IE and append this div to the top window BODY tag.  Please let me know if you can provide some insight.  

Lakio, would you still find the firefox screenshot helpful after my clarification?   Thanks for all your help.
0
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!

LakioCommented:
I made a small page, try it and tell me if thats want you want or/and send me a screenshot ;)

.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>Lakio made this</title>
	<script>
 
	function createDomElement( tag, where, text ) //  createElement ( 'div', document.body, 'The text in the div',  'Attribute1', 'Attribute1value',  'Attribute2', 'Attribute2value',  'Attribute3', 'Attribute3value'..... and so on )
	{
		with(document)
		{
			var element = createElement( tag );
			var a = arguments;
			
			for( var i=3; a[i]; i++ )
			{
				element.setAttribute( a[i++], a[i] );
			}
 
			text && element.appendChild( createTextNode(text) );
			where.appendChild( element );
			return element;
		}
	}
	
	function addSuperDiv( linkElm )
	{
		var element = createDomElement( 'div', document.body, 'The text in the div asdf asdfasdf asdf asdfa sdf ',  'id', 'superDiv', 'style', 'position:absolute; background:blue; top:80px' );
		element.style.left = '40px';
		
		linkElm.parentNode.removeChild( linkElm ); // deletes the link
	}
 
	</script>
</head>
<body>
	qwertyuiopðasdfghjklæ´zxcvbnm,.<br />
	qwertyuiopðasdfghjklæ´zxcvbnm,.<br />
	qwertyuiopðasdfghjklæ´zxcvbnm,.<br />
	qwertyuiopðasdfghjklæ´zxcvbnm,.<br />
	qwertyuiopðasdfghjklæ´zxcvbnm,.<br />
	qwertyuiopðasdfghjklæ´zxcvbnm,.<br />
	qwertyuiopðasdfghjklæ´zxcvbnm,.<br />
	qwertyuiopðasdfghjklæ´zxcvbnm,.<br />
 
	<a href="#" onclick="addSuperDiv(); return false">TEZT</a>
</body>
</html>

Open in new window

0
LakioCommented:
I forgot "this":
<a href="#" onclick="addSuperDiv( this ); return false">TEZT</a>
0
UnderSevenCommented:
Have you tried putting a z-index on it to make it independent of the rest of the page?
0
LakioCommented:
IE need to have it like this:

function addSuperDiv( linkElm )
{
	var element = createDomElement( 'div', document.body, 'The text in the div asdf asdfasdf asdf asdfa sdf ',  'id', 'superDiv' );
	element.style.position = 'absolute';
	element.style.left = '40px';
	element.style.top = '80px';
	element.style.background = '#F0C';
	
	linkElm.parentNode.removeChild( linkElm ); // deletes the link
}

Open in new window

0

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
mxyztplk333Author Commented:
Thank you, Lakio!  I really appreciate your help on this.
0
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
Web Development

From novice to tech pro — start learning today.