472,977 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Creating a div that obscures content beneath it

I'd be surprised if this isn't a FAQ; if it is, I must be searching on
the wrong keywords because I can find a lot of stuff about "how do I
make a div stick to the same area of the screen while the user scrolls
around" but what I want to do should be substantially simpler. I hope.

What I have so far works, but my new element just flows where it
normally would if it were at the end of the BODY and I'd like to be
able to get it to "float over" the rest of the page.

<html>
<head>
<title></title>
</head>

<body>
<script>
function test() {
var div = document.createElement('DIV')
div.style.position = 'absolute'
div.style.left = div.style.typ = '20px'
var h = document.createElement('H3')
h.appendChild(document.createTextNode('text'))
div.appendChild(h)
document.body.appendChild(div)
}
</script>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed eu
neque.
Duis lacinia volutpat lacus. Sed rutrum, nulla ac nonummy venenatis,
orci metus adipiscing ipsum, volutpat bibendum sapien nunc a purus.

<p>
<a href=javascript:test()>click here</a>
</body>
</html>

-Jonathan

Jul 23 '05 #1
4 1156
Ivo
"Jonathan Ellis" wrote
div.style.left = div.style.typ = '20px'


Here is my tip: change "typ" to "top".
HTH
--
Ivo

Jul 23 '05 #2
Jonathan Ellis wrote:
What I have so far works, but my new element just flows where it
normally would if it were at the end of the BODY and I'd like to be
able to get it to "float over" the rest of the page.


One of my friends got this working in mozilla, but IE6 doesn't like it:

function test() {
var div = document.createElement('DIV')
div.setAttribute("style","position:absolute; left:0px; top:0px;
width:600px; z-index:10000; background-color:#ff6600;");
var h = document.createElement('H3')
h.appendChild(document.createTextNode('text'))
div.appendChild(h)
document.body.appendChild(div)
}

Any suggestions?

-Jonathan

Jul 23 '05 #3
Ok, that was a good tip, but it still doesn't work. :)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #4
Ivo
"Jonathan Ellis" wrote
What I have so far works, but my new element just flows where it
normally would if it were at the end of the BODY and I'd like to be
able to get it to "float over" the rest of the page.


One of my friends got this working in mozilla, but IE6 doesn't like it:

function test() {
var div = document.createElement('DIV')
div.setAttribute("style","position:absolute; left:0px; top:0px;
width:600px; z-index:10000; background-color:#ff6600;");
var h = document.createElement('H3')
h.appendChild(document.createTextNode('text'))
div.appendChild(h)
document.body.appendChild(div)
}


Don't use setAttribute, but apply the styles directly:

div.style.position="absolute";
div.style.left="0";
div.style.top="0";
div.style.width="600px";
div.style.zIndex="100";
div.style.backgroundColor="#ff6600";

and IE will display it in the topleft corner.
--
Ivo
http://4umi.com/web/javascript/
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Headless | last post by:
A right aligned float next to a paragraph needs to be placed before the paragraph in the source, this causes the content order to be opposite in the visual and aural domain. Anyone know of a...
7
by: mercurius_1 | last post by:
I am having a problem with content being wrapped down the page in Internet Explorer. This is the page in question, which I have validated: www.lynngoldstein.com When the browser window is...
6
by: DraguVaso | last post by:
Hi, In my application, on some given actions while debugging in Visual Studio, I suddenly get a "System.ComponentModel.Win32Exception was unhandled" Message="Error creating window handle."...
12
by: Mats Lycken | last post by:
Hi, I'm creating a CMS that I would like to be plug-in based with different plugins handling different kinds of content. What I really want is to be able to load/unload plugins on the fly without...
15
by: David Thielen | last post by:
Hi; My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a subdirectory to display as part of the created page. However, the bitmap will not display due to a security violation. ...
2
by: CRPietschmann | last post by:
I'm using the Microsoft Virtual Earth Version 1 Commercial Control. I want to make it so you can click on a pinpoint that's plotted on the map and all mouse events are passed to the map so that the...
1
by: rfox | last post by:
I'm experiencing yet another only-in-IE problem. This time, when IE's window is reduced to a certain size, the main body of text jumps down beneath a side content box. In every other browser I've...
5
eragon
by: eragon | last post by:
I wrote this function to create a new file when the user posts in my forums, and its not creating a new file, can you help me? this script is not copyrighted as the last one. function...
0
by: Romulo NF | last post by:
Greetings again everyone Recently i´ve been asked to develop a script to allow filtering in the content of the table, with dinamic options based on the own content. Example: a table with the name of...
3
by: ColorWorld | last post by:
Hi there I am working on a site with a drop down menu. The post before mine had the same issue as mine in IE6; so i will follow that for that problem. Only i do have another problem. The drop...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.