Use JavaScript to get User Client resolution

Source: Internet
Author: User
Tags relative visibility client
Resolution | Client I made a Web navigation pull-down menu, with firework can be quickly generated, only to copy the code to the page on it, but the user side of the different resolution caused the drop down menu location of the move, how to 800 and 1024 of the menu to maintain the correct display, Modify a JS file in a function can be, y only need not change, only change the x coordinate variable can





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)//To 800*600 resolution settings


{


x = Movexbyslicepos (x-100, obj);


y = moveybyslicepos (y, obj);


}


if (window.screen.width==1024 && window.screen.height==768)//1024 Resolution settings


{


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].document.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.wid Th-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;


if (l.parentlayer.menucontainerbgcolor && l.menu.menubgopaque) L.parentlayer.document.bgcolor = L.parentlayer.menucontainerbgcolor;


}


}


l.visibility = "Inherit";


if (l.menu) l.menu.container.visibility = "Inherit";


} else if (Find ("MenuItem0")) {


var l = Menu.menulayer | | Menu


Hideactivemenus ();


if (typeof (L) = = "string") L = Find (l);


window. Activemenu = l;


var s = l.style;


s.visibility = "Inherit";


if (x!= "relative") {


s.pixelleft = x | | | (Window.pagex + document.body.scrollLeft) | | 0;


S.left = s.pixelleft + ' px ';


}


if (y!= "relative") {


s.pixeltop = y | | (Window.pagey + document.body.scrollTop) | | 0;


s.top = s.pixeltop + ' px ';


}


l.menu.xoffset = Document.body.scrollLeft;


l.menu.yoffset = Document.body.scrollTop;


}


if (menu) window.activemenus[window.activemenus.length] = l;


mm_cleartimeout ();


}

















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.