Use javascript to obtain the client resolution

Source: Internet
Author: User
Tags relative visibility
I made a webpage navigation drop-down menu, which can be quickly generated using firework. I only need to copy the code to the page. However, different resolutions on the user end lead to the movement of the drop-down menu position, how to keep the correct display under the menu of 800 and 1024, modify a function in the js file, y only needs to change the x coordinate variable.
Function MM_showMenu (menu, x, y, child, imgname ){
If (! Window. mmWroteMenu) return;
MM_clearTimeout ();
If (menu ){
Var obj = FIND (imgname) | document. images [imgname] | document. links [imgname] | document. anchors [imgname];
If (window. screen. width = 800 & window. screen. height = 600) // used for 800*600 resolution settings
X = movexbyserver POS (X-100, obj );
Y = moveYbySlicePos (y, obj );
If (window. screen. width = 1024 & window. screen. height = 768) // sets the resolution.
X = moveXbySlicePos (x, obj );
Y = moveYbySlicePos (y, obj );
If (document. layers ){
If (menu ){
Var l = menu. menuLayer | menu;
L. top = l. left = 1;
HideActiveMenus ();
If (this. visibility) l = this;
Window. ActiveMenu = l;
} Else {
Var l = child;
If (! L) return;
For (var I = 0; I <l. layers. length; I ++) {if (! L. layers [I]. isHilite) l. layers [I]. visibility = "inherit ";
If (l.layers+ I }.doc ument. layers. length> 0) MM_showMenu (null, "relative", "relative", l. layers [I]);
If (l. parentLayer ){
If (x! = "Relative") l. parentLayer. left = x | window. pageX | 0;
If (l. parentLayer. left + l. clip. width> window. innerWidth) l. parentLayer. left-= (l. parentLayer. left + l. clip. width-window. innerWidth );
If (y! = "Relative") l. parentLayer. top = y | window. pageY | 0;
If (l. parentLayer. isContainer ){
L. Menu. xOffset = window. pageXOffset;
L. Menu. yOffset = window. pageYOffset;
L. parentLayer. clip. width = window. ActiveMenu. clip. width + 2;
L. parentLayer. clip. height = window. ActiveMenu. clip. height + 2;
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.