如何将网页显示为警报

How to diplay a web page as alert

本文关键字:显示 网页      更新时间:2023-09-26

当我在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);