Home >Web Front-end >JS Tutorial >Javascript Tutorial: Learn more about PopUp objects

Javascript Tutorial: Learn more about PopUp objects

黄舟
黄舟Original
2016-12-15 10:53:032246browse

Javascript tutorial: In-depth study of PopUp objects

The company asked me to add a prompt function to an office system. I studied for a long time and tried many methods. I used window.open to prompt regularly, but after a while, the customer became impatient. It has to be said that the pop-up window is too complicated. So I thought of using the CreatePopup() method, but here comes the problem. Since it is an office system, we must consider compatibility issues. Instead of considering Netscape browser, we have to consider IE. 5.0 and IE 5.5 problems. IE 5.0 does not support the CreatePopup method, and can only be simulated with Window.open. So I wrote two implementation methods of prompt boxes, using the corresponding method based on the browser version. Tips The box effect is the same as the MSN prompt effect, but in IE 5.0, window.open is used instead of CreatePopup().

The MSN prompt box effect of window.open can only be seen in versions below IE 5.0.

No nonsense So much, let’s study the Popup object

The popup object is a borderless window. It is placed on top of any window. It must be controlled by script. Through javascript, we can control the position where it appears, and we can also write into it. Content. Note: If the content exceeds the display range after the size is fixed, the scroll bar will not appear. If the user clicks outside, it will automatically disappear. It uses the parent attribute to access the window that opens it.

1. Syntax

Create a popup object;

var popupobj=window.createPopup()

Access the properties and methods of the popup object from the document that created the popup window:

popupobj.property | method ([parameters])

2. Properties

document
popupobject.document

This attribute is the only way to create a script to the Popup object. For example,

popobj.document.body.style.border=”solid 1px #000000″ We can set a general border for the popup window .

isOpen
popupobject.isOpen
Return value: Boolean

If the pop-up window is visible, isOpen returns True, otherwise it is False.

3. Method

hide()
popupobject.hide()

Prompt, if If you want to add a button to close the pop-up window, you can do this: Assume the name of the pop-up window is popobj, then use parent.popobj.hide() to close itself

show(left,top,width, height[,positioningElementRef])

The default left and top are 0, which are the coordinates of the area displayed by the monitor, width and height are the width and height of the window.

The above is the Javascript tutorial: in-depth study of the content of the PopUp object, more related articles Please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn