Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-10-02
2
Medium Priority
?
1,228 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
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…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
Suggested Courses

971 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