Find position where HTML starts on page

D

daveyand

Hey Guys,

Am stuck, i need to create an overlaying DIV to a webpage, but i want
it to go over only the HTML content of the page. So if the page is
only within the middle 500px of the screen i want to be able to add my
overlay over that. And ignore the whitespace either side of it.

Does that make sense?

This div will be added via an ad stamp, so i wont be able to change the
page itself.

Any help, even something to look for/at would be much much appreciated.

Thanks in advance.

Andy
 
A

ASM

daveyand a écrit :
Am stuck, i need to create an overlaying DIV to a webpage, but i want
it to go over only the HTML content of the page. So if the page is
only within the middle 500px of the screen i want to be able to add my
overlay over that.

How do you expect to not have you div in the *window* ?
How can you display a *div* anywhere in the *screen* ?
Does that make sense?

Isn't it css's job ?

stylesheet :
============
html, body { height: 100% }
#addDiv { position: absolute; top: 50%; left: 50%;
width: 350px; height: 250px;
margin-top: -125px; margin-left: -175px;
border: 1px solid black;
overflow: scroll;
}

javascript :
============
function addStamp(stamp) {
var d = document.createElement('DIV');
d.id = 'addDiv';
d.innerHTML = stamp;
document.body.appendChild(d);
}

Not tested !
 
D

daveyand

The idea is to have something like this

function create_overlay() {
document.write("<div style='z-index: 1000;'>BLah</div>");
}

and have all the other stuff within it. As said this could be on any
page so i wouldnt be able to add stuff into the page on their side, nor
will i be able to get them to add to much into th page either.

If that makes sense? So i could have the div on this current form
page, or the google homepage, or the Yahoo homepage and it should all
work the same, in taht it adds a floating div the same size as all the
HTML on the page and displays stuff. An annoying overlay advert type
thing.
 
A

ASM

daveyand a écrit :
The idea is to have something like this

function create_overlay() {
document.write("<div style='z-index: 1000;'>BLah</div>");
}

If that makes sense? So i could have the div on this current form
page, or the google homepage, or the Yahoo homepage

you have Google or Yahoo personalized home pages ?
(where you can write)

try (copy-paste in notepad) :

<html>
<script type="text/javascript">
function addStamp(stamp) {
var d = document.createElement('DIV');
d.id = 'addDiv';
d.onclick = function() { this.style.display='none'; }
d.innerHTML = stamp;
document.body.appendChild(d);
}
var myStamp = 'that is only to see what happens. ';
for(var i=0;i<10;i++){myStamp+=myStamp;}
</script>
<style type="text/css" media="screen">
#addDiv { position: fixed; top: 50%; left: 50%;
width: 350px; height: 250px;
margin-top: -125px; margin-left: -175px;
border: 1px solid black;
overflow: scroll; background: lightyellow;
}
p { height: 350px; border: 1px solid red;}
</style>
<p> blah 1</p>
<p><a href="javascript:addStamp(myStamp)">stamp</a></p>
<p>blah 2</p>
</html>


IE will not like this fixed div :-(
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top