Creating Floating Div works in IE but not FireFox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PETERMCHARRIS
    New Member
    • Feb 2008
    • 1

    Creating Floating Div works in IE but not FireFox

    This code works in IE (pops up the div) but not in firefox, I cannot see why, any ideas?

    [CODE=javascript]function creatediv(id, html, width, height, left, top) {

    if (document.getEl ementById(id) != null) {
    removediv(id);
    }

    var newdiv = document.create Element('div');
    newdiv.setAttri bute('id', id);

    document.body.a ppendChild(newd iv);

    if (width) {
    document.getEle mentById(id).st yle.width = 300;
    }

    if (height) {
    document.getEle mentById(id).st yle.height = 300;
    }

    if ((left || top) || (left && top)) {
    document.getEle mentById(id).st yle.position = "absolute";

    if (left) {
    document.getEle mentById(id).st yle.left = left;
    }

    if (top) {
    document.getEle mentById(id).st yle.top = top;
    }
    }

    document.getEle mentById(id).st yle.background = "lightyello w";
    document.getEle mentById(id).st yle.border = "4px solid #000";

    if (html) {
    document.getEle mentById(id).in nerHTML = html;
    } else {
    document.getEle mentById(id).in nerHTML = "nothing";
    }

    document.getEle mentById(id).st yle.filter='alp ha(opacity=75)' ; // IE Semi Transparent Setting
    document.getEle mentById(id).st yle.opacity='0. 75'; // FireFox Semi transparent Setting

    }
    function removediv(id) {
    var d = document.getEle mentById(id);
    document.body.r emoveChild(d);
    }[/CODE]
    Last edited by gits; Feb 21 '08, 10:50 AM. Reason: added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    [CODE=javascript]
    if (width) {
    document.getEle mentById(id).st yle.width = 300;
    }

    if (height) {
    document.getEle mentById(id).st yle.height = 300;
    }[/CODE]300 what? Use "px", e.g. 300 + "px".

    Comment

    Working...