如何将网页显示为警报
How to diplay a web page as alert
当我在asp.net网格视图中单击一个按钮时,它将执行行命令,在那里我必须编写代码来打开特定的页面。。。如何做到这一点。
我相信您正在寻找javascript的window.open()
。这里有一个例子:
// from W3Schools
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>This is 'myWindow'</p>");
myWindow.focus();
如果你想阅读更多关于它的信息,请尝试W3Schools,这里有你想知道的大部分信息。
请记住,这些额外的弹出窗口会大大降低用户体验,尤其是在网络应用程序上,因此如果可能的话,您可能需要找到替代方案
我建议使用弹出窗口来使用提醒框。
查看此链接-下方的实时示例和此代码参考
<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>
<script>
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "explode",
duration: 1000
}
});
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
});
});
</script>
<div id="dialog" title="Basic dialog">
<iframe src="ShowDetails.aspx"></iframe>
</div>
<button id="opener">Open Dialog</button>
您可以通过编程创建一个iframe并将其添加到页面中。如果你绝对定位它,它会出现在页面的其他内容的顶部。
HTML:
<a href="javascript:void(0);" id="button">click me</a>
JavaScript:
var button = document.getElementById("button");
button.addEventListener("click", function() {
var frame = document.createElement("IFRAME");
var body = document.querySelector("body");
var width = 300;
var height = 200;
frame.setAttribute("src", "http://www.w3schools.com/tags/tag_iframe.asp");
frame.setAttribute("style", "position: absolute; top: 50%; left: 50%; margin-left: -" + (width/2) + "px; margin-top: -" + (height/2) + "px");
body.appendChild(frame);
});
这里有一个jsfiddle演示它是如何工作的http://jsfiddle.net/krasimir/LkcLX/1/
p.S。请注意,您应该在click事件处理程序中设置宽度、高度和url。
这里得到了答案:如何在gridview的rowcommand事件中的新选项卡中打开页面?
String js = "window.open('Signature.aspx', '_blank');";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Open Signature.aspx", js, true);
相关文章:
- 在 Angular 应用程序的弹出窗口中显示网页
- Javascript:从网页中获取文本,更改它,然后再次显示网页
- 如何显示网页中使用的超链接列表
- 提取并使用javascript / greasemonkey显示网页
- 使用 iframe 显示网页的一部分
- 如何在显示网页时调用脚本 jquery
- 如何防止双击使用 JavaScript 突出显示网页文本
- 使用 Apache 模块和 Javascript/jQuery 显示网页的最后修改日期
- 显示网页时使用了两个或多个 CSS 样式
- 如何使用phonegap显示网页
- 突出显示网页上的文本
- 不同的操作系统对显示网页的影响有多大
- 设置进度条动画以显示网页的进度
- 如何使用.js文件使用document.write()显示网页
- IE8中的问题,使用引导程序显示网页
- 是否可以从我的Chrome扩展在窗口中显示网页,只使用JS、HTML和CSS
- jQuery:只在document.ready后显示网页
- 自动计数和显示网页上的单词数
- 在IOS和Windows上显示网页图像的方法
- 如何从url在html页面中显示网页