IDK Posted October 19, 2005 Share Posted October 19, 2005 I making a site, but I don't know how to write crossbrowser code.This works fine in Firefox, but don't in IE...I tried to improve the code by doing like I've seen other's do, like adding the short if statement... //IDKfunction updatetitle(){ if (ie4||ns6){ var titletext=document.getElementById? document.getElementById("titletext") : titletext; var theiframe=document.getElementById? document.getElementById("theiframe") : theiframe; var leftline=document.getElementById? document.getElementById("leftline") : leftline; var rightline=document.getElementById? document.getElementById("rightline") : rightline; titletext.innerHTML=theiframe.contentDocument.title; var titlelength=theiframe.contentDocument.title.length; leftline.width= 350 - titlelength * 5; rightline.width= 310 - titlelength * 5; }}} How do I make it work?titletext is a spanthe lines are imgI'm an experienced programmer, but javascript is to messy, almost messier that asm... Link to comment Share on other sites More sharing options...
actionsketch Posted October 19, 2005 Share Posted October 19, 2005 Well, I'm not real familiar with contentDocument but I took a shot at fixing anything I could see as not working...the only real problem I saw was when you were referencing leftline.width, you have to use leftine.style.width. here's what I came up with: function updatetitle(){ if (ie4||ns6){ var titletext=document.getElementById("titletext"); var theiframe=document.getElementById("theiframe"); var leftline=document.getElementById("leftline"); var rightline=document.getElementById("rightline"); titletext.innerHTML=theiframe.contentDocument.title; var titlelength=theiframe.contentDocument.title.length; leftline.style.width= 350 - titlelength * 5; rightline.style.width= 310 - titlelength * 5; }}} Link to comment Share on other sites More sharing options...
IDK Posted October 21, 2005 Author Share Posted October 21, 2005 Thanks for you reply, but I need it to work with IE. Otherwise my site would be very bad.Do anyone know how to write such a script Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now