Alternative to Javascript's prompt() for Google Chrome Web App

你说的曾经没有我的故事 提交于 2019-12-01 22:38:20

window.prompt has two features:

  1. It requests input from the user.
  2. It does this in a synchronous way, i.e. execution of JavaScript in your page is suspended until prompt() returns.

The first feature can be emulated, but the second feature cannot. So, you will be able to get user input, but only in an asynchronous way. There are two ways to prompt the user for input:

  1. In a popup.
  2. In a lightbox.

A lightbox is similar to a popup, except that it's embedded in the page itself. All implementations of a lightbox involve at least two containers:

  1. A div that covers the whole page, so that the user cannot click on anything else. (CSS: position:fixed;top:0;left:0;width:100%;height:100%;z-index:1000;)
  2. Other HTML elements that together resemble a dialog (input fields, buttons).

There are plenty of existing UI libraries to show an inline dialog, e.g. jQuery UI.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!