Home >Web Front-end >JS Tutorial >The pop-up prompt box based on jquery is always in the center of the window (similar to the effect of the alert pop-up box)_jquery
The principle is very simple:
Get the width and height of the current screen (form), because the form sizes of different browsers are different. With this, the vertically centered coordinates can be calculated. But how can it still be vertically centered after sliding the scroll bar? At this time, you need to get the height of the current form from the top of the page and add it to the y-axis coordinate just now.
$(document) gets the entire web page, $(window) gets the current form, this needs to be clarified.
Finally, just assign the obtained coordinates to the form. The form itself is absolutely positioned, so it can naturally go to the middle of the form.
Specific code:
Are you sure you want to delete it?