473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to set margin-left in IE w/Javascript

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!

Aug 24 '06 #1
4 54534
guywmustang wrote:
[...]
I'm trying to do this in javascript

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

document.getElementById("Picture").style.marginLef t = "200px";

<URL:
http://www.w3.org/TR/DOM-Level-2-Sty...ies-marginLeft
>
}

Except, that doesn't set the margin properly in IE. In FF & opera it
works fine.
Not for me - I get an error "invalid assignment left-hand side" as
expected.

--
Rob

Aug 24 '06 #2
Sorry.... my code actually says:

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

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

Aug 24 '06 #3
guywmustang wrote:
Sorry.... my code actually says:

function setMargin()
{
document.getElementById("Picture").style.marginLef t = "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.marginLef t = '200px';
"></p>
--
Rob

Aug 24 '06 #4
guywmustang wrote:
>
[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?
Aug 26 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Brian | last post by:
I have a page with content, navigation, and footer divs, in that order. The nav div has position: absolute, width 8em, on green background. The other divs have an 8em green left border, such that...
19
by: Thomas Mlynarczyk | last post by:
Hello, The following gives different results in IE and "Non-IE" browsers: <div style="background-color: green; width: 200px"> <div style="margin-top: 20px; background-color: red"> Hello...
1
by: Marek Mänd | last post by:
I have question regarding (clearing) floats and margin-top on DL and HR elements. http://www.hot.ee/idaliiga/testcases/dl/language-chosing-selector.htm Namely the IE6 doesnt calculate the...
2
by: Stanimir Stamenkov | last post by:
I'm trying to clear some sizing issues relative to the initial containing block and the root document element. The sample document I'm trying with: http://stanio.info/viewport_fill.html ...
13
by: Cool Guy | last post by:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>test</title> </head> <body> <div style="height: 100px; width: 100px;...
3
by: xen | last post by:
Hey there, In my html file I use a <div class="quote">. In my css file I define .quote I need to specify the margins for <pinside the <div> Today I learned that I can do this using ..quote p...
2
by: Steve Richter | last post by:
I want my panel to have an inner margin. Problem is label text does not appear to recognize the margin. In this example, the TextBox aligns on the margin, the label does not: <asp:Panel...
0
by: GTalbot | last post by:
Hello fellow stylesheet colleagues, Load this url: http://www.gtalbot.org/BrowserBugsSection/DefaultTopBottomMarginsForPargDisappear.html I would appreciate it if someone could explain 1-...
2
by: GTalbot | last post by:
www.authoring.html] Hello fellow HTML and markup coder colleagues, Please visit this url: http://www.gtalbot.org/BrowserBugsSection/DefaultTopBottomMarginsForPargDisappear.html I would...
7
by: GTalbot | last post by:
Hello fellow authoring.stylesheets colleagues, Can someone please explain why the bottom margin of the last inflow block-level child in an overflowed parent should not have its margin reachable....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.