【问题标题】:How to Include links in html or jquery alert boxes?如何在 html 或 jquery 警报框中包含链接?
【发布时间】:2016-10-26 16:31:56
【问题描述】:

当网站加载时,我只想要一个提供链接的警告框。
我认为我们无法在 JavaScript 警告框中添加链接。
有什么方法可以在网站加载时将链接包含在警告框中的任何其他框中?
提前致谢。

【问题讨论】:

  • 您不能将链接放在 AlertBox (javascript) 中,答案中有一些实现。它是一个基于具有显示/隐藏事件的 div 的对话框。

标签: php jquery html hyperlink


【解决方案1】:

您可以使用Jquery UI dialog box 在页面加载时在弹出窗口中显示所有链接。

您可以在 jquery ui 对话框中显示所需的 html

请参考:https://jqueryui.com/dialog/

还有一些其他插件可用于在弹出窗口中显示数据。

【讨论】:

    【解决方案2】:

    使用 window.confirm 而不是 alert

    if (window.confirm('If you click "ok" you would be redirected . Cancel will load this website ')) 
    {
      window.location.href='https://www.google.com/chrome/browser/index.html';
    };
    

    【讨论】:

      【解决方案3】:

      是的,您可以使用包含链接的警告框。

      这是通过使用充当警报框的自定义模式来完成的。

      http://jquerymodal.com/ 提供了有关如何做到这一点的示例。

      【讨论】:

        【解决方案4】:

        试试这个

        if (window.confirm('redirecting the website to google')) 
            {
              window.location.href='https://www.google.com/';
            };
        

        【讨论】:

          猜你喜欢
          • 2018-01-23
          • 1970-01-01
          • 1970-01-01
          • 2011-05-12
          • 2013-01-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多