Closed Thread Icon

Topic awaiting preservation: Centering Javascript in <head> tag of webpage (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=21549" title="Pages that link to Topic awaiting preservation: Centering Javascript in &amp;lt;head&amp;gt; tag of webpage (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Centering Javascript in &lt;head&gt; tag of webpage <span class="small">(Page 1 of 1)</span>\

 
JSThePatriot
Obsessive-Compulsive (I) Inmate

From:
Insane since: Apr 2004

posted posted 04-26-2004 21:09

I have some javascript I got from dynamicdrive.com and I am trying to center the whole nav bar.

Here is the script.

code:
<html>
<head>
<title>The-Patriot.Net by Patriot Designs</title>
<link href="patriotnet.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="navcond.js"></script>
<script language="JavaScript">

var myNavBar1 = new NavBar(0);
var dhtmlMenu;

dhtmlMenu = new NavBarMenu(100, 0);
dhtmlMenu.addItem(new NavBarMenuItem("Home", "http://www.the-patriot.net/"));
myNavBar1.addMenu(dhtmlMenu);

dhtmlMenu = new NavBarMenu(100, 120);
dhtmlMenu.addItem(new NavBarMenuItem("Shop", "http://www.the-patriot.net/shop.cfm"));
myNavBar1.addMenu(dhtmlMenu);

dhtmlMenu = new NavBarMenu(110, 120);
dhtmlMenu.addItem(new NavBarMenuItem("Login", "http://www.the-patriot.net/login.cfm"));
myNavBar1.addMenu(dhtmlMenu);

dhtmlMenu = new NavBarMenu(100, 150);
dhtmlMenu.addItem(new NavBarMenuItem("Contact Us", "http://www.the-patriot.net/contactus.cfm"));
myNavBar1.addMenu(dhtmlMenu);

dhtmlMenu = new NavBarMenu(100, 150);
dhtmlMenu.addItem(new NavBarMenuItem("About Us", "http://www.the-patriot.net/aboutus.cfm"));
myNavBar1.addMenu(dhtmlMenu);


myNavBar1.setColors("#000000", "#000000", "#C0C0C0", "#ffffff", "#666666", "#000000", "#cccccc", "#ffffff", "#000080")


myNavBar1.setAlign("center")

var fullWidth;

function init() {

fullWidth = getWindowWidth()
- (isMinNS4 && getWindowHeight() < getPageHeight() ? 16 : 0);

myNavBar1.resize(680);
myNavBar1.create();
myNavBar1.setzIndex();
myNavBar1.moveTo(0, 150);
}
</script>
</head>

<body onload="init()">

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

posted posted 04-26-2004 21:19

And??? Are you having a problem? If so, what exactly is the problem?


. . : DHTML Slice Puzzle : . . . : Justice 4 Pat Richard : . .

JSThePatriot
Obsessive-Compulsive (I) Inmate

From:
Insane since: Apr 2004

posted posted 04-26-2004 22:46

The above code doesnt center the navbar. I just made it center by doing some math... but now my problem is it wont recenter after resize.



Please help if you can.

JS

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

posted posted 04-26-2004 22:52

Can you post a link to the page so I can see what's going on? Also, if the problem is just on the resize, then do you know whether this code is designed to handle the onresize event? I'm not familiar with the code on dynamicdrive because I'm usually too busy writing my own.


. . : DHTML Slice Puzzle : . . . : Justice 4 Pat Richard : . .

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 04-27-2004 18:46

Here's what I'd do.

somewhere in the top stick a flag

var initialized = false;


in the bottom of the init function stick

initialized = true;

then make a new function.

function checkresize() {
if ( initialized ) init();
}

Finally somewhere in the head stick

window.onResize = checkresize();

Basically what should happen is if the user resizes, then it runs the checkresize function. If the nav has already been initialized then it runs the init again which repositions the nav. If init hasn't happend then it will just wait for the body onload event to occur which will then fire the init function.



.:[ Never resist a perfect moment ]:.

trib
Paranoid (IV) Inmate

From: Den Haag, Netherlands
Insane since: Sep 2002

posted posted 04-27-2004 19:07

how about

code:
<body onload="init()" onresize="init()">




Bug-free software only exisits in two places
In programmer's mind and on a salesman's lips

(Edited by trib on 04-27-2004 10:08)

« BackwardsOnwards »

Show Forum Drop Down Menu