Jump to content

Floating div


johnrb87

Recommended Posts

Hello

 

I have been editing the following script

 

<style type="text/css">
div.dm
{
    visibility: hidden;
    position:absolute;
    left:100px;
    top:200px;
    font-family:verdana;
    font-weight:bold;
    padding:40px;
background-color:#066;
border:2px solid #009;

}
</style>
<script>
function buildDimmerDiv()
{
    document.write('<div id="dimmer" class="dm">Quick Help<br>To use this page...</div>');
}
</script>
If you need help <a onClick="buildDimmerDiv()">click here</a>
<br><br>
<strong>Introduction</strong>
<br>
Welcome to the....

 

But I can't seem to get it to react how I want.

 

1: It does not seem to load the CSS called "dm"

 

2: It seems to replace all page content rather than floating ontop of content

 

Basically when I click the "click here" link, I wanted it to display a floating div so I can provide a quick help guide

 

Can anyone help?

Link to comment
Share on other sites

that's because document.write() will overwrite the current document.  You should either hardcode the div on the page somewhere and make it initially hidden and then change the content of the div (and the styling to make it visible etc...) or create an object and append it to the current dom (research document.append).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.