Jump to content

IE 7 sucks - but what else is new?


brittny85

Recommended Posts

I'm working on a website for a client and I need to change the ID of the body if a certain condition is met.  I have code that works great in all browsers... except IE 7.  Anyone know why the following line of code would crash IE 7, and no other browser?  Any ideas of a different way to make this work?

 

document.getElementById('t2').id

 

Thanks!

-Brittny

Link to comment
Share on other sites

So I got some help from a friend, but I'm no closer to figuring out how to do what I need to do.  We changed the code to:

var docid = document.getElementById('t2');
docid.id = 'home';

 

The page only crashed when I added in the second line, so it's definitely the changing the id that is crashing IE, not the getting the element.  Any thoughts on what I could do otherwise?

Link to comment
Share on other sites

Well, I didn't really figure out why IE does this or how to make it actually change the ID of an object using Javascript, however I did come up with a passable workaround.  Since I was just using the IDs to apply different CSS styles I changed tactics and added a class name instead.  I then modified my CSS to reflect this change. 

 

document.getElementById('full_page').className = 'home';

 

Anyways, hopefully this is helpful to someone else down the line as well.

Link to comment
Share on other sites

I thought about using JQuery, but it isn't really practical for the application at hand.  The tool my client is having me use won't allow me to import external files, so I'd have to paste the whole JQuery library in a script tag in the header, which would make editing the template a little unwieldy.  But that's definitely a good idea for people that don't have this limitation!  Thanks :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.