Help with Javascript - IE problems

Discussion in 'JavaScript' started by Trommsdorff, Aug 11, 2006.

  1. #1
    Hi all,

    Usually I can get a script working in IE and then fix it for firefox, but now i have the opposite problem - it works fine in Firefox but not IE!

    IE *does* render something, although it puts the advert script (starting on line 9) at the very end, after the close of the last table. Firefox displays it as I have intended it (Ad inside the table).

    No matter where I put the embedded advert script in the following code, it ALWAYS is shown at the end in IE. With firefox, it moves around as could be expected.


    
    if (screen.availWidth>800) {
    document.write("<iframe src='sidebar_dark.htm' width='170' height='1075' scrolling=no frameborder=0></iframe><br>");
    document.write("<table cellpadding='0' cellspacing='0' border='0' class='tborder' width='170' align='center'>");
    document.write("<tr>");
    document.write("<td calign='center'>");
    document.write("<table cellpadding='4' cellspacing='1' border='0' width='100%'>");
    document.write("<tr align='center'><td class='thead'><span class='bigyel'>Sponsor Links</span></td></tr>");
    document.write("<tr><td class='smallfont' bgcolor='#3B3B3B'>");
    document.write("<scr"+"ipt language='JavaScript'");
    document.write("src='http://4.adbrite.com/mb/text_group.php?sid=XXXXXX'>");
    document.write("</scr"+"ipt>");
    document.write("<p />");
    document.write("<div><a class='adHeadline' target='_blank' href='http://www.adbrite.com/mb/commerce/purchase_form.php?opid=XXXXX'>Place Your Ad Here</a></div>");
    document.write("</td></tr></table></td></tr></table>");
    }
    else;
    
    Code (markup):
    I am pretty new to JavaScript and all in all not so good with code, so I appreciate any advice you guys have!
     
    Trommsdorff, Aug 11, 2006 IP
  2. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #2
    To begin with screen.availWidth isn't always available in all browsers. Here's some more options:

    window.innerWidth
    document.documentElement.clientWidth
    document.body.clientWidth

    And more importantly, does your page validate as XHTML? If not, fix that before continuing.
     
    exam, Aug 12, 2006 IP