Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Menu Script Refresh

Status
Not open for further replies.

kyern

Programmer
Mar 30, 2006
36
US
I have a small problem with a menu script I am using called Jim's DHTML Menu. Every time the page resizes it calculates its position on the page and then performs a page reload. I really like this feature but I would like to find a way to have the script change position without the page reload - it messes with several javascript forms.

Code:
function floatMenu(scrWidth, scrHeight, mrgLeft, adjustNum)
{
	if (this.isMainMenu)
	{
		var bodyWidth = 0, mrg = 0;
		if (docType)
		{
			mrg = mrgLeft + 10;
			bodyWidth = document.getElementsByTagName("BODY")[0].offsetWidth;
		}
		else
		{
			mrg = 10;
			bodyWidth = document.body.scrollWidth;
		}

		if (adjustNum == 0 || adjustNum == 2)
		{
			var menuLeft = Math.ceil(this.main.offsetLeft + (screen.width - scrWidth)/2);
			this.main.style.left = Math.ceil(menuLeft - (screen.width - bodyWidth)/2 + mrg);
			this.iframe.style.left = this.main.offsetLeft;
		}
		if (adjustNum == 1 || adjustNum == 2)
		{
			this.main.style.top = this.main.offsetTop + (screen.height - scrHeight)/2;
			this.iframe.style.top = this.main.offsetTop;
		}

		if (this.hasShadow)
		{
			this.shadow.style.left = this.main.offsetLeft + this.sOffX;
			this.shadow.style.top = this.main.offsetTop + this.sOffY;
			this.siframe.style.left = this.shadow.offsetLeft;
			this.siframe.style.top = this.shadow.offsetTop;
		}

		window.onresize = new Function("location.reload();");
		
	}
}

This is the portion of the script that is responsible for the update. Is there any way to update this so it doesn't use location.reload?
 
Sorry I may not be clear enough. I still want to use the onresize event. Is there a different way i can recalulate the position and move the script on the page to that location without reloading the page and destroying my js forms?

I've seen where objects have been animated on the screen in js before does anyone have any insight into that process?

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top