Javascript 在asp.net中弹出我的新页面
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14031707/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Open my new page in pop up in asp.net
提问by
I have a regular page.When i clicked on a button it will be open in that page with some asp controls. what i need is that i want to open that page in a pop up page with close button inside it.I searched but i didn't find a properly cod for this. can any body help me?
thanks

我有一个常规页面。当我点击一个按钮时,它将在该页面中打开,并带有一些 asp 控件。我需要的是我想在一个弹出页面中打开该页面,里面有关闭按钮。我搜索过,但我没有找到合适的鳕鱼。有谁能够帮助我?谢谢

采纳答案by user3076772
<script type="text/javascript">
function OpenPopup() {
window.open("ProductClass.aspx", "List", "toolbar=no, location=no,status=yes,menubar=no,scrollbars=yes,resizable=no, width=900,height=500,left=430,top=100");
return false;
}
</script>
回答by Elad Lachmi
You can use windows.open in javascript.
您可以在 javascript 中使用 windows.open。
<html>
<body>
<script type="text/javascript">
function windowOpen() {
myWindow=window.open('http://myurl.com','_blank','width=200,height=100, scrollbars=no,resizable=no')
myWindow.focus()
}
</script>
<input type="button" value="Open Window" onclick="windowOpen()">
</body>
</html>
回答by ????
Use return before your function
在函数之前使用 return
<html>
<body>
<script type="text/javascript">
function windowOpen() {
myWindow=window.open('http://myurl.com','_blank','width=200,height=100, scrollbars=no,resizable=no')
myWindow.focus()
return false;
}
</script>
<asp:button id="btnClick" text="Open Window" onClientClick="return windowOpen()">
</body>
</html>
回答by Sumant
Use the below code
使用下面的代码
ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "window.location.href = 'Home.aspx';", true);
ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "window.location.href = 'Home.aspx';", true);
回答by suraj gorad
hi all Kindly use the below code
大家好请使用下面的代码
function ShowPopup() {
$("#panOne").dialog({
autoOpen: true,
appendTo: "form",
height: 600,
width: 900
});
}
appendTo: "form"is Important as if you are not using it will autopostbackall values
appendTo:"form"很重要,就好像您不使用它一样将autopostback所有值

