JavaScript makes a floating tool bar

Source: Internet
Author: User
Tags filter eval return tagname window
javascript| Float | tool bar

This program is I from other people's website analysis out! Because the other side of the Web site using the framework, but also canceled the right mouse button function, so the cost of a good long time!
When you browse the page, the sidebar is always floating in the upper left corner, if you do not like, you can adjust the placement position! If you want to use the code more than one page, you can put the JSP program part of the file as JS, and then through the call to achieve, there is no understanding of the place, welcome you to communicate with me!
Demo Address:http://www.85time.com/softuse/bar.htm
<HTML>
<HEAD>
<TITLE></TITLE>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<style type= "Text/css" >
. wdblack{font-size:9pt; line-height:11pt font-family: XXFarEastFont-Arial Color:black}
. wdgray{font-size:9pt; line-height:11pt font-family: XXFarEastFont-Arial; color: #CCCCCC}
. wdblue{font-size:9pt; line-height:11pt font-family: XXFarEastFont-Arial; color: #2F8BDF}
. wdred{font-size:9pt; line-height:11pt font-family: XXFarEastFont-Arial Color:red}
. wdwhite{font-size:9pt; line-height:11pt font-family: XXFarEastFont-Arial Color:white}
. Moveme{cursor:move;}
. Handle{cursor:move;}
. Coolbar{background: #fffffc; border-top:1px solid buttonhighlight; border-left:1px solid; border-bottom:1px solid Buttonshadow; border-right:1px solid Buttonshadow; padding:2px; Font:menu;}
. coolbutton{font-size:9pt;border:1px solid buttonface padding:1px; text-align:center; Cursor:hand;color: #555555}
. Coolbutton IMG {Filter:gray ();} div{font-size:9pt; line-height:11pt; font-family: Song Body; Color:black}
text{font-size:9pt; line-height:11pt font-family: Song Body; Color:black}
input{font-size:9pt; line-height:11pt font-family: Song Body; Color:black}
table{font-size:9pt; line-height:11pt font-family: Song Body; Color:black}
body{font-size:9pt; line-height:11pt font-family: Song Body; Color:black}
form{font-size:9pt; line-height:11pt font-family: Song Body; Color:black}

a:link{font-size:9pt font-family: song body; text-decoration:none; color: #2F8BDF}
a:visited{font-size:9pt font-family: song body; text-decoration:none; color: #2F8BDF}
a:hover{font-size:9pt font-family: song body; text-decoration:underline; color: #FF0000}
</STYLE>

<script language= "JavaScript" >
var dragobject = null;
var tx;
var Ty;
Document.onmouseover = Doover;
Document.onmouseout = Doout;
Document.onmousedown = Dodown;
Document.onmouseup = Doup;
Document.onmousedown=initdown;
Document.onmouseup=initup;
Document.onmousemove=initmove;
function stat () {
var a = pageYOffset;
Document.bar.top = A;
SetTimeout (' stat () ', 2);
}
function fix () {
Nome=navigator.appname
if (nome== ' Netscape ') stat ();
else{
var a=document.body.scrolltop;
var b=document.body.scrollleft;
Bar.style.top = A;
Bar.style.left = b;
}
}
function Getreal (EL) {
temp = El;
while (temp!= null) && (temp.tagname!= "Body") {
if ((Temp.classname = = "Moveme") | | (Temp.classname = = "Handle")) {
el = temp;
Return el;
}
temp = temp.parentelement;
}
Return el;
}
function Moveme_onmousedown () {
el = Getreal (window.event.srcElement)
if (El.classname = = "Moveme") {
Dragobject = El;
ty = (window.event.clienty-dragobject.style.pixeltop);
tx = (window.event.clientx-dragobject.style.pixelleft);
Window.event.returnValue = false;
Window.event.cancelBubble = true;
}else if (El.classname = = "Handle") {
TMP = El.getattribute ("for");
if (tmp!= null) {
el = eval (tmp);
Dragobject = El;
ty = (window.event.clienty-dragobject.style.pixeltop);
tx = (window.event.clientx-dragobject.style.pixelleft);
Window.event.returnValue = false;
Window.event.cancelBubble = true;
} else {
Dragobject = null;
}
}else {
Dragobject = null;
}
}
function Moveme_onmouseup () {
if (dragobject) {
Dragobject = null;
}
}
function Moveme_onmousemove () {
if (dragobject) {
if (Window.event.clientX >= 0) {
Dragobject.style.left = WINDOW.EVENT.CLIENTX-TX;
Dragobject.style.top = Window.event.clienty-ty;
}
Window.event.returnValue = false;
Window.event.cancelBubble = true;
}
}
if (document.all) {
Document.onmousedown = Moveme_onmousedown;
Document.onmouseup = Moveme_onmouseup;
Document.onmousemove = Moveme_onmousemove;
}
function Doover () {
var Toel = getreal (window.event.toElement, "ClassName", "Coolbutton");
var Fromel = getreal (window.event.fromElement, "ClassName", "Coolbutton");
if (Toel = = Fromel) return;
var el = Toel;
var cdisabled = el.cdisabled;
cdisabled = (cdisabled!= null);
if (El.classname = = "Coolbutton")
El.onselectstart = new Function ("return false");
if ((El.classname = = "Coolbutton") &&!cdisabled) {
Makeraised (EL);
Makegray (El,false);
}
}
function Doout () {
var Toel = getreal (window.event.toElement, "ClassName", "Coolbutton");
var Fromel = getreal (window.event.fromElement, "ClassName", "Coolbutton");
if (Toel = = Fromel) return;
var el = Fromel;
var cdisabled = el.cdisabled;
cdisabled = (cdisabled!= null);
var ctoggle = El.ctoggle;
toggle_disabled = (ctoggle!= null);
if (Ctoggle && el.value) {
Makepressed (EL);
Makegray (el,true);
}
else if ((El.classname = "Coolbutton") &&!cdisabled) {
Makeflat (EL);
Makegray (el,true);
}
}
function Dodown () {
el = Getreal (window.event.srcElement, "ClassName", "Coolbutton");
var cdisabled = el.cdisabled;
cdisabled = (cdisabled!= null);
if ((El.classname = = "Coolbutton") &&!cdisabled) {
Makepressed (EL)
}
}
function Doup () {
el = Getreal (window.event.srcElement, "ClassName", "Coolbutton");
var cdisabled = el.cdisabled;
cdisabled = (cdisabled!= null);
if ((El.classname = = "Coolbutton") &&!cdisabled) {
Makeraised (EL);
}
}
function Getreal (el, type, value) {
temp = El;
while (temp!= null) && (temp.tagname!= "Body") {
if (eval ("temp." + type) = = value) {
el = temp;
Return el;
}
temp = temp.parentelement;
}
Return el;
}
function Findchildren (el, type, value) {
var children = El.children;
var tmp = new Array ();
var j=0;
for (var i=0; i<children.length; i++) {
if (eval ("children[i]." + type + "=" "+ Value +" "")) {
Tmp[tmp.length] = Children[i];
}
TMP = Tmp.concat (Findchildren (children[i], type, value));
}
return TMP;
}
function Disable (EL) {
if (document.readystate!= "complete") {
Window.settimeout ("Disable (" + el.id + ")", 100);
Return
}
var cdisabled = el.cdisabled;
cdisabled = (cdisabled!= null);
if (!cdisabled) {
El.cdisabled = true;
el.innerhtml = ' <span style= ' Background:buttonshadow; width:100%; height:100%; text-align:center;border:1px ">" +
' <span style= ' Filter:mask (color=buttonface) DropShadow (Color=buttonhighlight, Offx=1, OffY=1, Positive=0); height:100%; width:100%%; text-align:center;border:1px ">" +
El.innerhtml +
' </span> ' +
' </span> ';
if (El.onclick!= null) {
El.cdisabled_onclick = El.onclick;
El.onclick = null;
}
}
}
function Enable (EL) {
var cdisabled = el.cdisabled;
cdisabled = (cdisabled!= null);
if (cdisabled) {
el.cdisabled = null;
el.innerhtml = el.children[0].children[0].innerhtml;
if (El.cdisabled_onclick!= null) {
El.onclick = El.cdisabled_onclick;
El.cdisabled_onclick = null;
}
}
}
function Addtoggle (EL) {
var cdisabled = el.cdisabled;
cdisabled = (cdisabled!= null);
var ctoggle = El.ctoggle;
Ctoggle = (ctoggle!= null);
if (!ctoggle &&!cdisabled) {
El.ctoggle = true;
if (El.value = null)
El.value = 0;
if (El.onclick!= null)
El.ctoggle_onclick = El.onclick;
Else
El.ctoggle_onclick = "";
El.onclick = new Function ("Toggle" ("+ El.id +"); "+ El.id +". Ctoggle_onclick (); ");
}
}
function Removetoggle (EL) {
var cdisabled = el.cdisabled;
cdisabled = (cdisabled!= null);
var ctoggle = El.ctoggle;
Ctoggle = (ctoggle!= null);
if (Ctoggle &&!cdisabled) {
El.ctoggle = null;
if (El.value) {
Toggle (EL);
}
Makeflat (EL);
if (El.ctoggle_onclick!= null) {
El.onclick = El.ctoggle_onclick;
El.ctoggle_onclick = null;
}
}
}
function Toggle (EL) {
El.value =!el.value;
if (El.value)
El.style.background = "URL ()";
Else
El.style.backgroundImage = "";
}
function Makeflat (EL) {
With (El.style) {
Background = "";
border = "1px solid buttonface";
padding = "1px";
}
}
function maeraised (EL) {
With (El.style) {
Borderleft = "1px solid #2F8BDF";
BorderRight = "1px solid #2F8BDF";
BorderTop = "1px solid #2F8BDF";
BorderBottom = "1px solid #2F8BDF";
padding = "1px";
}
}
function makepressed (EL) {
With (El.style) {
Borderleft = "1px solid buttonhighlight";
BorderRight = "1px solid Buttonshadow";
BorderTop = "1px solid buttonhighlight";
BorderBottom = "1px solid Buttonshadow";

Paddingtop = "2px";
Paddingleft = "2px";
Paddingbottom = "0px";
paddingright = "0px";
}
}
function Makegray (el,b) {
var filtval;
if (b)
Filtval = "Gray ()";
Else
Filtval = "";
var IMGs = Findchildren (el, "TagName", "IMG");
for (var i=0; iImgs[i].style.filter = Filtval;
}
}
function Load (WS) {
Parent.location.href=ws;
}
function Initdown () {
Dodown ();
Moveme_onmousedown ();
}
function Initup () {
Doup ();
Moveme_onmouseup ();
}
function Initmove () {
Moveme_onmousemove ();
}
</script>
</HEAD>
<body onscroll= "fix ()" onresize= "fix ()" >
<span id= "Bar" style= "position:absolute;left:0px;top:0px;width:500px; height:1px; Z-index:9 ">
<table Class=coolbar id=toolbar1 width=100%>
<tr>
&LT;TD Class=coolbutton > User Forum </td>
&LT;TD Class=coolbutton > Utility engine </td>
&LT;TD Class=coolbutton > Recommended Works </td>
&LT;TD Class=coolbutton > Message Board </td>
&LT;TD Class=coolbutton > Chat room </td>
</tr>
</table>
</span>
</body>


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.