473,386 Members | 1,796 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,386 software developers and data experts.

problem with document.body.appendChild() on IE

I am trying to display loading prompt by creating elements using javascript
Expand|Select|Wrap|Line Numbers
  1. var text = document.createElement('div');
  2.                                 text.innerHTML = '<br/><center>Loading........Please Wait!</center>';
  3.                                 text.style.height = "80px";
  4.                                 text.style.width = "350px";
  5.                                 text.style.background = "#000";
  6.                                 text.style.opacity = 0.7;
  7.                                 text.style.color = '#fff';
  8.                                 var header = document.createElement('span');
  9.                                 header.innerHTML = "";
  10.                                 header.style.height = "50px";
  11.                                 header.style.width = "350px";
  12.                                 header.appendChild(text);
  13.                                 header.style.position = "absolute";
  14.                                 header.id = "Loadingmsg1";
  15.                                 $(header).css('top', '250px');
  16.                                 $(header).css('left', '300px');
  17.                                 document.body.appendChild(header);
When i debug this code on chrome once the last line is excuted it shows up the message but not on IE(tested on ver 9)
where i am getting wrong? Please help
Sep 17 '12 #1
2 2659
Rabbit
12,516 Expert Mod 8TB
In, IE, elements are not available for use until it has loaded. You need to put your code in a function and then call said function in the onload event of the body.
Sep 17 '12 #2
iam_clint
1,208 Expert 1GB
I actually don't see a problem with your code I tested in firefox and ie the only difference i made to your code was that i got rid of the jquery and directly set the style properties?
Sep 22 '12 #3

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

Similar topics

6
by: skubik | last post by:
Hi everyone. I'm attempting to write a Javascript that will create a form within a brand-new document in a specific frame of a frameset. The problem is that I can create the form and input...
7
by: Sundew Shin | last post by:
Hi, I'm wanting to check the availability of the 'document.body' element. In Mozilla and IE, the function below: window.onload = function(){ alert(document.body); }; alerts '' or '', so I...
14
by: christopher.secord | last post by:
Can someone please tell me why this works: document.body.innerHTML = "<table><tr><th>one</th></tr><tr><td>two</td></tr></table>"; But this does not work: document.body.innerHTML =...
2
by: Earl Teigrob | last post by:
I am trying to build a custom control to wrap my smart navigation implimention (not microsofts 'cause it has problems) The follow code works fine when the onclick and onload events are defined in...
25
by: MeNotHome | last post by:
I am automating the navigation of a website. When I reach the end, it changes to xml. So my axwebbrowser1 has a bunch of xml data in it. So here is what I am trying to do Dim xmlText As...
3
by: ezmiller | last post by:
So I have some code that gets the body element of another frame and then tries to dynamically write a table. The code fails when, after creating the table, I try to append it to the document. I...
2
by: Smugsboy | last post by:
Hi, Got a problem here. I'm trying to create a bookmarklet on IE6, that passes the outerHTML of the body element as a GET param my site. The problem is that for some page (ie mail.yahoo.com) the...
4
by: jnag | last post by:
Hello, Through an onClick() event, I have an inline function to change the font size of the page (actually, I need to do this for the entire website). I have this defined in the header.cfm file...
3
by: jnag | last post by:
I am trying to implement font changer, where I have links on the banner of the site and when the user clicks on the links, the font size of the page has to change. I tried...
4
by: kiransasi | last post by:
hi all, i m herewith struck with this problem.... check out the following code and lemme know the solution for this.... <html> <heAD> <TITLE>WAIT</TITLE>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.