How to set margin-left in IE w/Javascript

G

guywmustang

I basically have this....

<div id="page">
<div id="leftPane">
picture previews
</div>
<div id="Picture">
A picture here
</div>
</div>

I'm trying to do this in javascript

function setMargin()
{
document.getElementById("Picture").style.margin-left = "200px";
}

Except, that doesn't set the margin properly in IE. In FF & opera it
works fine.

Any ideas??? Thanks!
 
R

RobG

G

guywmustang

Sorry.... my code actually says:

function setMargin()
{
document.getElementById("Picture").style.marginLeft = "200px";
}

And it still doesn't set properly for IE....
 
R

RobG

guywmustang said:
Sorry.... my code actually says:

function setMargin()
{
document.getElementById("Picture").style.marginLeft = "200px";
}

And it still doesn't set properly for IE....

Then there is something else in the 'real' page that is stopping it
from working in IE. I suggest posting to:

news:comp.infosystems.www.authoring.stylesheets


A link to the relevant page, or an example, will really help. As a
test, the following works in IE and Firefox at least:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<title>Margin play</title>
<div id="page">
<div id="leftPane">
picture previews
</div>
<div id="Picture">
A picture here
</div>
</div>
<p><input type="button" value="Indent div" onclick="
document.getElementById('Picture').style.marginLeft = '200px';
"></p>
 
T

The Magpie

guywmustang said:
[snip] Except, that doesn't set the margin properly in IE. In FF & opera it
works fine.

Any ideas??? Thanks!
Wouldn't this be far better done with CSS anyway? Or is CSS still not
reliable in IE?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top