Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Find position where HTML starts on page

Reply
Thread Tools

Find position where HTML starts on page

 
 
daveyand
Guest
Posts: n/a
 
      10-25-2006
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

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      10-25-2006
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 !

--
ASM
 
Reply With Quote
 
 
 
 
daveyand
Guest
Posts: n/a
 
      10-25-2006
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.

 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      10-25-2006
daveyand a écrit :
> The idea is to have something like this
>
> function create_overlay() {
> document.write("<div style='z-index: 1000;'>BLah</div>");
> }


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
..
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where is Form Relative Position and Absolute Position in VS.Net 2005 ? Luqman ASP .Net 1 02-07-2006 10:27 AM
position image based on document position edouard.lauer@pt.lu Javascript 3 01-14-2006 06:04 PM
Find An Object's Page Position On Any Page - Version 0.1 Matt Kruse Javascript 1 08-14-2005 11:02 PM
How to set position of a web control depending on other control's position at run-time? James Wong ASP .Net Web Controls 4 07-14-2004 10:24 AM
Instant Messenger starts when Outlook Express 6 starts no matter what is checked! Route9w Computer Support 11 07-08-2004 01:13 PM



Advertisments