Find position where HTML starts on page

Discussion in 'Javascript' started by daveyand, Oct 25, 2006.

  1. daveyand

    daveyand Guest

    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
     
    daveyand, Oct 25, 2006
    #1
    1. Advertising

  2. daveyand

    ASM Guest

    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
     
    ASM, Oct 25, 2006
    #2
    1. Advertising

  3. daveyand

    daveyand Guest

    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.
     
    daveyand, Oct 25, 2006
    #3
  4. daveyand

    ASM Guest

    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 :-(
    ..
     
    ASM, Oct 25, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Sturgeon

    Debugger Starts Old Version of ASPX Page??

    Ken Sturgeon, Dec 22, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    462
    Ken Sturgeon
    Dec 22, 2005
  2. Wybo Dekker
    Replies:
    1
    Views:
    381
    Yukihiro Matsumoto
    Nov 15, 2005
  3. vdvorkin
    Replies:
    0
    Views:
    425
    vdvorkin
    Feb 10, 2011
  4. Matt Kruse
    Replies:
    1
    Views:
    133
  5. Daz
    Replies:
    6
    Views:
    120
Loading...

Share This Page