Solved

How to change style / styles with document.getElementById for IE7 ?

Posted on 2008-10-02
2
1,216 Views
Last Modified: 2013-12-08
I want to change DIV-styles through javascript with the use of document.getElementById
This works for IE6 and FireFox but for IE7 it does not work.
It seems that IE7 only accepts a style-change once, when you add another style for the same id it does not work or simply disappears.

Code:


   
document.getElementById('ctl00_mainContent_UcCatalog1_cart').style.top = '';
document.getElementById('ctl00_mainContent_UcCatalog1_cart').style.height = '200px'; //does not work for IE7
document.getElementById('ctl00_mainContent_UcCatalog1_cart').style.overflow = 'hidden'; //does not work for IE7

Open in new window

0
Comment
Question by:geertbro
2 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22624938
it works fine for me . try this
<div id="ddd" onmouseover="c ();" onmouseout="c2 ();">HEllo</div>

<script language="javascript">
function c () {
document.getElementById('ddd').style.height='100px';
document.getElementById('ddd').style.overflow = 'hidden';
}

function c2 () {
document.getElementById('ddd').style.height='500px';
document.getElementById('ddd').style.overflow = 'visible';
}
</script>
0
 
LVL 1

Accepted Solution

by:
geertbro earned 0 total points
ID: 22789857
It had somethinh to do with the Doctype but also on the other hand rendering in IE7.
I fixed it with providing the correct Doctype, and added sufficient styling & javascript-workarounds.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Several part series to implement Internet Explorer 11 Enterprise Mode
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question