How to Make Simple Note using HTML JavaScript
Submitted by alpha_luna on Monday, July 25, 2016 - 11:32.
This simple note script was created using HTML and JavaScript. You can use it for broadcast special events or news in your site. You can easily be dismissed it, and users allow to specify the Frequency of its appearance, it's either once per session browser or every time the page loaded. Lastly, in any browser, you can drag the note where you want to place it.
Second, insert this code below to your BODY section, better at the bottom of a page.
This two script copy and paste below your markup in your page.
Just download the source code and use it to your project. Hope this work will help you. Try it yourself and enjoy coding.
Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.
Direction:
First, kindly copy this codes below into the HEAD section of your page.- <style type="text/css">
- #post_the_note {
- position:absolute;
- width:523px;
- padding:5px;
- background-color:azure;
- border:2px solid blue;
- visibility:hidden;
- z-index:100;
- font-size:15px;
- font-family:cursive;
- }
- </style>
- <div id="post_the_note" style="left:100px;top:100px"><!---don't delete the style tag, for drag purposes-->
- <div align="right">
- <b>
- </b>
- </div>
- <!---your content-->
- <br />
- <p>
- <a href="http://www.sourcecodester.com/" title="Sourcecodester" target="_new">
- Looking for free source code?
- </a>
- <br />
- Kindly visit this site, <a href="http://www.sourcecodester.com/" style="text-decoration:none;" title="Sourcecodester" target="_new">
- </a>
- </p>
- <p>
- <a href="http://www.sourcecodester.com/" title="Sourcecodester" target="_new">
- Do you have source code, articles, tutorials, web links, and books to share?
- </a>
- <br />
- What are you waiting for? <a href="http://www.sourcecodester.com/" style="text-decoration:none;" title="Sourcecodester" target="_new">
- </a>
- </p>
- <!---end your content-->
- </div>
- <script type="text/javascript" language="JavaScript">
- //once per browser session to post?
- //(0=no, 1=yes)
- var once_per_browser=0
- var ns4=document.layers
- var ie4=document.all
- var ns6=document.getElementById&&!document.all
- if (ns4)
- crossobj=document.layers.post_the_note
- else if (ie4||ns6)
- crossobj=ns6? document.getElementById("post_the_note") : document.all.post_the_note
- //for closing
- function closeit(){
- if (ie4||ns6)
- crossobj.style.visibility="hidden"
- else if (ns4)
- crossobj.visibility="hide"
- }
- //the cookie name
- function get_cookie(Name) {
- var search = Name + "="
- var returnvalue = "";
- if (document.cookie.length > 0) {
- offset = document.cookie.indexOf(search)
- if (offset != -1) { // if cookie exists
- offset += search.length
- // set index of beginning of value
- end = document.cookie.indexOf(";", offset);
- // set index of end of cookie value
- if (end == -1)
- end = document.cookie.length;
- returnvalue=unescape(document.cookie.substring(offset, end))
- }
- }
- return returnvalue;
- }
- function showornot(){
- if (get_cookie('postdisplay')==''){
- showit()
- document.cookie="postdisplay=yes"
- }
- }
- function showit(){
- if (ie4||ns6)
- crossobj.style.visibility="visible"
- else if (ns4)
- crossobj.visibility="show"
- }
- if (once_per_browser)
- showornot()
- else
- showit()
- </script>
- <script type="text/javascript" language="JavaScript">
- // for the drag function
- function drag_drop(e){
- if (ie4&&dragapproved){
- crossobj.style.left=tempx+event.clientX-offsetx+'px'
- crossobj.style.top=tempy+event.clientY-offsety+'px'
- return false
- }
- else if (ns6&&dragapproved){
- crossobj.style.left=tempx+e.clientX-offsetx+'px'
- crossobj.style.top=tempy+e.clientY-offsety+'px'
- return false
- }
- }
- function initializedrag(e){
- if (ie4&&event.srcElement.id=="post_the_note"||ns6&&e.target.id=="post_the_note"){
- offsetx=ie4? event.clientX : e.clientX
- offsety=ie4? event.clientY : e.clientY
- tempx=parseInt(crossobj.style.left)
- tempy=parseInt(crossobj.style.top)
- dragapproved=true
- document.onmousemove=drag_drop
- }
- }
- document.onmousedown=initializedrag
- document.onmouseup=new Function("dragapproved=false")
- </script>
Image Sample Output

The Complete Code
- <!DOCTYPE html>
- <html>
- <head>
- <style type="text/css">
- #post_the_note {
- position:absolute;
- width:523px;
- padding:5px;
- background-color:azure;
- border:2px solid blue;
- visibility:hidden;
- z-index:100;
- font-size:15px;
- font-family:cursive;
- }
- </style>
- </head>
- <body>
- <div id="post_the_note" style="left:100px;top:100px"><!---don't delete the style tag, for drag purposes-->
- <div align="right">
- <b>
- </b>
- </div>
- <!---your content-->
- <br />
- <p>
- <a href="http://www.sourcecodester.com/" title="Sourcecodester" target="_new">
- Looking for free source code?
- </a>
- <br />
- Kindly visit this site, <a href="http://www.sourcecodester.com/" style="text-decoration:none;" title="Sourcecodester" target="_new">
- </a>
- </p>
- <p>
- <a href="http://www.sourcecodester.com/" title="Sourcecodester" target="_new">
- Do you have source code, articles, tutorials, web links, and books to share?
- </a>
- <br />
- What are you waiting for? <a href="http://www.sourcecodester.com/" style="text-decoration:none;" title="Sourcecodester" target="_new">
- </a>
- </p>
- <!---end your content-->
- </div>
- <script type="text/javascript" language="JavaScript">
- //once per browser session to post?
- //(0=no, 1=yes)
- var once_per_browser=0
- var ns4=document.layers
- var ie4=document.all
- var ns6=document.getElementById&&!document.all
- if (ns4)
- crossobj=document.layers.post_the_note
- else if (ie4||ns6)
- crossobj=ns6? document.getElementById("post_the_note") : document.all.post_the_note
- //for closing
- function closeit(){
- if (ie4||ns6)
- crossobj.style.visibility="hidden"
- else if (ns4)
- crossobj.visibility="hide"
- }
- //the cookie name
- function get_cookie(Name) {
- var search = Name + "="
- var returnvalue = "";
- if (document.cookie.length > 0) {
- offset = document.cookie.indexOf(search)
- if (offset != -1) { // if cookie exists
- offset += search.length
- // set index of beginning of value
- end = document.cookie.indexOf(";", offset);
- // set index of end of cookie value
- if (end == -1)
- end = document.cookie.length;
- returnvalue=unescape(document.cookie.substring(offset, end))
- }
- }
- return returnvalue;
- }
- function showornot(){
- if (get_cookie('postdisplay')==''){
- showit()
- document.cookie="postdisplay=yes"
- }
- }
- function showit(){
- if (ie4||ns6)
- crossobj.style.visibility="visible"
- else if (ns4)
- crossobj.visibility="show"
- }
- if (once_per_browser)
- showornot()
- else
- showit()
- </script>
- <script type="text/javascript" language="JavaScript">
- // for the drag function
- function drag_drop(e){
- if (ie4&&dragapproved){
- crossobj.style.left=tempx+event.clientX-offsetx+'px'
- crossobj.style.top=tempy+event.clientY-offsety+'px'
- return false
- }
- else if (ns6&&dragapproved){
- crossobj.style.left=tempx+e.clientX-offsetx+'px'
- crossobj.style.top=tempy+e.clientY-offsety+'px'
- return false
- }
- }
- function initializedrag(e){
- if (ie4&&event.srcElement.id=="post_the_note"||ns6&&e.target.id=="post_the_note"){
- offsetx=ie4? event.clientX : e.clientX
- offsety=ie4? event.clientY : e.clientY
- tempx=parseInt(crossobj.style.left)
- tempy=parseInt(crossobj.style.top)
- dragapproved=true
- document.onmousemove=drag_drop
- }
- }
- document.onmousedown=initializedrag
- document.onmouseup=new Function("dragapproved=false")
- </script>
- </body>
- </html>
Add new comment
- 100 views