在两个网站之间创建一个弹出窗口

时间:2013-06-21 13:50:48

标签: c# javascript asp.net

在我们的网站上,我们有另一页的链接。这看起来像这样

<a href="URL" title="Title" class="thisClass">
  <img src="IMG"  width="20" border="0"/>
</a>

我想要的是,当点击链接时,会弹出一个弹出窗口。此信息: “您尝试输入的页面包含xx图像,可能需要很长时间才能加载。你确定你要继续吗” xx是可以从存在链接的网站给出的变量。 那么当然应该在弹出窗口上有一个OK和CANCEL按钮。如果单击“确定”按钮,则将URL加载到浏览器,如果单击“取消”,则不会发生任何操作(返回原始页面)

该网站使用asp.net c#编程。

我们对新网页不感兴趣,但只是一个简单的javascript弹出窗口,给用户一个警告,由于xx数量的图片,网页加载速度很慢。

此网页用于内部网站点,我们希望在用户进入我们预计需要很长时间才能加载的网站时向用户发出警告。

3 个答案:

答案 0 :(得分:1)

查看jQuery UI对话框(http://jqueryui.com/dialog/)或Twitter的Bootstrap模式(http://twitter.github.io/bootstrap/javascript.html#modals

我认为这两种解决方案都能满足您的需求。

答案 1 :(得分:0)

<a href="URL" title="Title" onclick="return confirm('The page you are trying to enter has xx images and can take long time to load. Are you sure you want to continue?');" class="thisClass">
 <img src="IMG"  width="20" border="0"/>
</a>

如果您可以使用常规浏览器的提示框,请尝试此操作。否则,你将不得不求助于其他jquery插件,使其看起来更优雅,在其他答案中提到。

答案 2 :(得分:0)

您可以为此使用JqueryUi,此库包含符合您需要的Dialog。

这是网站: http://jqueryui.com/dialog/#default

我在这个网址中找到的代码示例:

<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>jQuery UI Dialog - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script>
  $(function() {
    $( "#dialog" ).dialog();
  });
  </script>
</head>
<body>

<div id="dialog" title="Basic dialog">
  <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>


</body>
</html>

还有管理确认的例子(按钮OK和按钮CANCEL)

我希望我帮助你;)

相关问题