ldb358 Posted August 30, 2009 Share Posted August 30, 2009 okay I'm making an "i.m. bar" that is supposed to be placed perfectly center on my web site, to make it easier to use in other projects i have it all done in JavaScript but on internet explorer and only internet explorer it is giving me an error on this code: imbar.style.left = ((window.innerWidth - 960)/2)+"px"; imbar.style.right = ((window.innerWidth - 960)/2) +"px"; its giving me this error when i use the debugger invalid argument line 7 character 5 invalid argument line 8 character 5 I've tried messing with gettting rid of the px and other things but then it breaks it in all of the browsers heres the script its from: function imbar(){ var newimbar = document.createElement('div'); newimbar.setAttribute('id', 'imbar'); document.getElementById('imbarholder').appendChild(newimbar); var imbar = document.getElementById('imbar'); imbar.style.width = "940px"; imbar.style.left = ((window.innerWidth - 960)/2)+"px"; imbar.style.right = ((window.innerWidth - 960)/2) +"px"; imbar.style.height = "25px"; imbar.style.background = "#FFFFCC"; imbar.style.border = "3px solid #000000"; imbar.style.borderBottom = "none"; imbar.style.position = "fixed"; imbar.style.bottom = "0px"; imbar.innerHTML = "<span id='onlineFriends' onclick='getFriends()'>Select a Friend to Chat With</span>"; } thanks in advance Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted August 31, 2009 Share Posted August 31, 2009 It's because window.innerWidth doesn't exist in IE. use document.body.offsetWidth for IE instead. Quote Link to comment Share on other sites More sharing options...
ldb358 Posted August 31, 2009 Author Share Posted August 31, 2009 Thank you very much Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.