JS control elements display in the screen fixed position and monitor the height of the screen changes the method _javascript skills

Source: Internet
Author: User

The example of this article is about how the JS control element is displayed in the fixed position of the screen and the monitor screen height changes. Share to everyone for your reference. Specifically as follows:

Control the display position of the logo Begin
window.addeventlistener ("Resize", function () {
  //Get screen size (internal/external width, internal/external height)
  Changelogoposition ();
}, False);
Changelogoposition ();
function Changelogoposition () {
  var contentheight = $ ("#main_content_div"). CSS ("height");
  var logoheight = $ ("#third_party_logo"). CSS ("height");
  Contentheight = parseint (contentheight.replace (' px ', '));
  Logoheight = parseint (logoheight.replace (' px ', '));
  Alert (' Screen height: ' +document.body.scrollheight+ ' content height: ' +contentheight+ ' logo height: ' +logoheight ');
  if (Document.body.scrollheight-contentheight > Logoheight) {
    document.getElementById (' Third_party_logo '). style.position = ' absolute ';
  } else {
    document.getElementById (' Third_party_logo '). style.position = ';
  }
}
Control the display position of the logo end

I hope this article will help you with your JavaScript programming.

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.