473,320 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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?

Expand|Select|Wrap|Line Numbers
  1. function creatediv(id, html, width, height, left, top) {
  2.  
  3.    if (document.getElementById(id) != null) {
  4.        removediv(id);
  5.    }
  6.  
  7.    var newdiv = document.createElement('div');
  8.    newdiv.setAttribute('id', id);
  9.  
  10.    document.body.appendChild(newdiv);
  11.  
  12.    if (width) {
  13.        document.getElementById(id).style.width = 300;
  14.    }
  15.  
  16.    if (height) {
  17.        document.getElementById(id).style.height = 300;
  18.    }
  19.  
  20.    if ((left || top) || (left && top)) {
  21.        document.getElementById(id).style.position = "absolute";
  22.  
  23.        if (left) {
  24.            document.getElementById(id).style.left = left;
  25.        }
  26.  
  27.        if (top) {
  28.            document.getElementById(id).style.top = top;
  29.        }
  30.    }
  31.  
  32.    document.getElementById(id).style.background = "lightyellow";
  33.    document.getElementById(id).style.border = "4px solid #000";
  34.  
  35.    if (html) {
  36.        document.getElementById(id).innerHTML = html;
  37.    } else {
  38.        document.getElementById(id).innerHTML = "nothing";
  39.    }
  40.  
  41.    document.getElementById(id).style.filter='alpha(opacity=75)'; // IE Semi Transparent Setting
  42.    document.getElementById(id).style.opacity='0.75'; // FireFox Semi transparent Setting
  43.  
  44. function removediv(id) {
  45.   var d = document.getElementById(id);
  46.   document.body.removeChild(d);
  47. }
Feb 21 '08 #1
1 1285
acoder
16,027 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1.    if (width) {
  2.        document.getElementById(id).style.width = 300;
  3.    }
  4.  
  5.    if (height) {
  6.        document.getElementById(id).style.height = 300;
  7.    }
300 what? Use "px", e.g. 300 + "px".
Feb 21 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Oliver Bryant | last post by:
I just finished developing a javascipt component allowing floating captions to appear over HTML elements. If anyone wants to check it out you can see specs and download it from...
12
by: meltedown | last post by:
I would like the floating divs to float and then the header to come after them , on the left. That's what I thought clearing the floats was for, but in this example, the header is to the right of...
15
by: Mike Driscoll | last post by:
Hi, I've had this niggling issue from time to time. I want to create a shortcut on the user's desktop to a website that specifically loads Firefox even if Firefox is not the default browser. ...
6
by: Kreauchee | last post by:
Hi, So I'm somewhat baffled by this. I've looked online and found several solutions but none seem to be working for me. I have an xml file like this: <manatee num="6723-MT"> <stuff></stuff>...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.