创建“你确定吗?”仅使用 html 弹出窗口

发布于 2024-11-03 19:00:51 字数 113 浏览 1 评论 0原文

假设我有一个 html,它包含一些提交类型。我想创建一个“您确定吗”弹出窗口,当用户单击提交按钮时会出现该窗口。 我的问题是有什么方法可以通过“仅”html而不是使用javascript或任何其他方式来创建它?

Assume I have a html from, and it contain some submit type. I want to create a "are you sure" popup window that will appear when user click submit button.
My question is that is there any way to create it by using "only" html, not using javascript or any other?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

心是晴朗的。 2024-11-10 19:00:51

仅 HTML 是可能的,但没有回发

就无法在没有 javascript 的情况下工作:

  1. 您的表单带有提交按钮
  2. 用户单击(并提交)表单
  3. 您显示另一个表单,其中包含 您确定吗? 表单 ( 原始数据功能所需的操作成为可能
  4. 包含按钮以及第一个表单的隐藏字段,使执行操作的 这种

这将完全不需要 Javascript,但它需要多次回发,

事情通常是在客户端使用 Javascript confirm() 函数完成的。 (这是一个简单的示例)或最近提供了一个更用户友好的模式对话框许多不同的客户端库或其插件。

何时选择脚本免费版本?

如果您知道您的客户端将是非常基本的客户端(即,绝大多数用户将使用无法运行的 Opera Mini 等客户端访问您的应用程序)脚本)。但在所有其他情况下,使用 Javascript 来完成此操作要好得多。它将更快、更容易开发并且更加用户友好。更不用说它也会减轻服务器的压力,因为某些部分将在客户端上执行,而不需要任何服务器处理。

HTML only is possible, but not without a postback

Scenario that could work without javascript:

  1. You have your form with submit button
  2. User clicks (and submits) the form
  3. You display another form with are you sure? form (that contains Yes and No buttons as well as hidden fields of the first form that will make it possible to do the action required on the original data
  4. functionality that executes the action and goes back to whatever required.

This would be completely Javascript free, but it would require several postbacks.

This kind of thing is usually done on the client with a Javascript confirm() function (here's a simple example) or lately with a more user friendly modal dialog provided by many different client libraries or their plugins.

When to choose the script free version?

If you know your clients are going to be very basic ones (ie. vast majority of your users will access your application using clients like Opera Mini that's not able to run scripts at all). But in all other cases it's much better to do this using Javascript. It will be faster, easier to develop and much more user friendly. Not to mention that it will put less strain on your server as well since certain parts will execute on the client without the need of any server processing.

蓝礼 2024-11-10 19:00:51

不,没有。尽管 HTML 5 具有新功能,HTML 仍然是一种标记语言,而不是一种编程语言。为了表达动态行为(例如“您确定吗?”框),您需要使用编程语言。

Javascript 将是最明显的选择,但您也可以使用可以帮助您手动编写 Javascript 的框架(例如 ASP.NET)来实现此目的。

编辑:实际上,理论上来说,无需 Javascript 或其他框架就可以做到这一点。正如我刚刚了解到的, HTML 5 + CSS 3 似乎已经完成。但这与这个问题几乎无关。

No, there isn't. Despite of the new features in HTML 5, HTML is still a markup language, not a programming language. In order to express dynamic behavior (such as an "are you sure?" box), you need to use a programming language.

Javascript would be the most obvious choice for this, but you could also do it with frameworks that can get you around writing Javascript by hand (for example ASP.NET).

Edit: Actually it appears that it would theoretically possible to do this with without Javascript or other frameworks. As I just learned, HTML 5 + CSS 3 seems to be turing complete. But this is hardly relevant to this question.

梦断已成空 2024-11-10 19:00:51

可以要求确认,但不会出现在“弹出窗口”中。创建“弹出窗口”需要javascript/其他语言。

它将是:

  1. 请求(第一个表单)
  2. POST
  3. 响应(确认表单)
  4. POST
  5. 响应(结果消息)

您可以创建一个表单,其中包含第一个表单中的数据的所有隐藏元素以及“是”和“否”按钮位于“你确定吗?”文本。您可以使用 PHP 会话来避免隐藏表单元素。如果有大量数据或机密数据,或者您不想重新验证第二个表单中的数据,请使用会话。请确保在使用前验证任一表单中的数据。

It's possible to ask for a confirmation, but it will not be in a "popup window". The creation of the "popup window" requires javascript/other language.

It will be:

  1. Request (first form)
  2. POST
  3. Response (confirmation form)
  4. POST
  5. Response (outcome message)

You can create a form with all hidden elements containing the data from the first form and a "Yes" and "No" button below the "Are you sure?" text. You can use PHP sessions to avoid the hidden form elements. If there is a lot of data or confidential data or you do not want to re-validate the data from the second form, use sessions. Make sure you validate the data from either form before using it.

心舞飞扬 2024-11-10 19:00:51

我知道我迟到了 10 年。但对于仍然想知道的人,我想我可以提供一些帮助!
我针对这个具体问题所做的就是确保我的代码中有多个“div”。具体对我来说,我有两个主要的。
第一个是 id="main",另一个是 id="popup",弹出 div 的 'visible' 属性最初设置为 'false'。

然后,无论您要查找哪个事件(例如单击按钮),您只需设置 main.Visible = falsepopup.Visible = true,然后您就可以弹出窗口中有更多按钮(是、否、取消、确认等),它们执行完全相同的操作,但方向相反!

要确保的最重要的事情是您的 div 中具有“runat="server"”属性,以便您可以在 CS 代码中访问它们

希望这对您有帮助! :)

I know I'm like .. 10 years late. But for anyone still wondering I thought I could be of some help!
What I did for this exact problem was make sure I had multiple "divs" in my code. For me specifically, I had two main ones.
First, one whose id="main", and another whose id="popup" with the 'visible' property initially set to 'false' for the popup div.

Then, on whichever event you're looking for (button click for example) you'll simply set main.Visible = false and popup.Visible = true, then you could have more buttons in your popup (yes, no, cancel, confirm, etc.) which do the exact same thing, but in reverse!

The most important thing to make sure of is that you have the 'runat="server"' property in your divs so that you can access them in your CS code

Hope this was helpful! :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文