About the top of the blog scroll navigation bar code _javascript Tips

Source: Internet
Author: User
Many friends in various ways asked me to Blog at the top of the scroll navigation menu code. In fact, there is nothing special, but since there is demand, I would like to put this part of the code out, for your reference.
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<HEAD>
<title>float div</title>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<style type= "Text/css" >
#zealNavigatorBar {
Position:absolute;
z-index:100;
width:760px;
height:32px;
line-height:32px;
top:0px;
left:0px;
padding:0px;
margin:0px;
border-bottom:1px solid #646465;
Background-color: #C0C0C3;
}
</style>
</HEAD>

<BODY>
<div id=zealnavigatorbar>
<a href= "/" >anything here</a>
<a href= "/" >anything here</a>
<a href= "/" >anything here</a>
</div>
<script language= "JavaScript" >
for (Var t=0;t<1000;t++) Document.writeln (' Test content:line ' +t+ ' <br/> ');
</script>
<script language= "JavaScript" >
var g_mybodyinstance = document.body;
var g_mybodyinstancestring = "Document.body";
if (Document.compatmode!= "Backcompat") {
For LOOSER.DTD
G_mybodyinstance = document.documentelement;
g_mybodyinstancestring = "Document.documentelement";
}
var isMinNS4 = (navigator.appName.indexOf ("Netscape") >= 0 &&
Parsefloat (navigator.appversion) >= 4)? 1:0;
var isMinNS5 = (navigator.appName.indexOf ("Netscape") >= 0 &&
Parsefloat (navigator.appversion) >= 5)? 1:0;
var isMinIE4 = (document.all)? 1:0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf ("5.") >= 0)? 1:0;
var Ismacie = (isMinIE4 && navigator.userAgent.indexOf ("Mac") >= 0)? 1:0;

var getffversion=navigator.useragent.substring (
Navigator.userAgent.indexOf ("Firefox")). Split ("/") [1];
Extra height in px to add to IFRAME in FireFox 1.0+ browsers
var ffextraheight=getffversion<1.5? 16:0;


function Getlayer (name) {
if (isMinNS5)
return document.getElementById (name);
else if (isMinIE4)
Return eval (' document.all. ' + name);
else if (isMinNS4)
Return Findlayer (name, document);

return null;
}

function Findlayer (name, doc) {

var i, layer;

for (i = 0; i < doc.layers.length; i++) {
layer = Doc.layers[i];
if (layer.name = = name)
return layer;
if (Layer.document.layers.length > 0) {
Layer = Findlayer (name, layer.document);
if (layer!= null)
return layer;
}
}

return null;
}

function Movelayerto (layer, x, y) {
if (isMinIE4) {
Layer.style.left = x;
Layer.style.top = y;
}
else if (isMinNS5) {
Layer.style.left = x+ ' px ';
Layer.style.top = y+ ' px ';
}
else if (isMinNS4)
Layer.moveto (x, y);
}

function Getpageleft (layer) {

if (isminie4| | ISMINNS5)
return (Layer.offsetleft);
else if (isMinNS4)
return (Layer.pagex);
Return (-1);
}

function Getpagetop (layer) {

if (isminie4| | ISMINNS5)
return (Layer.offsettop);
else if (isMinNS4)
return (Layer.pagey);
Return (-1);
}

function Getpagescrollx () {

if (isminie4| | ISMINNS5)
return (G_mybodyinstance.scrollleft);
else if (isMinNS4)
return (Window.pagexoffset);
Return (-1);
}

function getpagescrolly () {

if (isminie4| | ISMINNS5)
return (G_mybodyinstance.scrolltop);
else if (isMinNS4)
return (Window.pageyoffset);
Return (-1);
}

var g_p_zealnavigatorbar = null;
G_p_zealnavigatorbar = Getlayer (' Zealnavigatorbar ');
if (!isminie4) {g_p_zealNavigatorBar.style.position = ' fixed ';}
function Reposzealnavigatorbar () {
if (isMinIE4) {
try{
Movelayerto (G_p_zealnavigatorbar,
Getpageleft (G_p_zealnavigatorbar),
Getpagescrolly ());
}catch (e) {}
}
}
Window.onresize = Reposzealnavigatorbar;
Window.onscroll = Reposzealnavigatorbar;
Window.onload = Reposzealnavigatorbar;
</script>
</BODY>
</HTML>

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.