模态pop不是使用asp.net C#出现的,只是举了一个例子,但该示例不使用asp.net C# web窗体。
下面是我的设计代码。
<style type="text/css">
body { font: normal normal normal 10px/1.5 Arial, Helvetica, sans-serif; }
.ui-dialog-osx {
-moz-border-radius: 0 0 8px 8px;
-webkit-border-radius: 0 0 8px 8px;
border-radius: 0 0 8px 8px; border-width: 0 8px 8px 8px;
}
</style>
<link href="jquery-ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$("#dialog-message").dialog({
modal: true,
draggable: false,
resizable: false,
position: ['center', 'top'],
show: 'blind',
hide: 'blind',
width: 400,
dialogClass: 'ui-dialog-osx',
buttons: {
"I've read and understand this": function () {
$(this).dialog("close");
}
}
});
setInterval(function () {
$('#dialog-message').dialog('open');
setTimeout(function () {
$('#dialog-message').dialog('close');
}, 1000)
}, 2000);
</script>下面是我的身体设计代码。
<body>
<form id="form1" runat="server">
<div>
<p>
Hello World!
</p>
<div id="dialog-message" title="Important information">
<span class="ui-state-default"><span class="ui-icon ui-icon-info" style="float: left;
margin: 0 7px 0 0;"></span></span>
<div style="margin-left: 23px;">
<p>
We're closed during the winter holiday from 21st of December, 2010 until 10th of
January 2011.
<br />
<br />
Our hotel will reopen at 11th of January 2011.<br />
<br />
Another line which demonstrates the auto height adjustment of the dialog component.
</p>
</div>
</div>
</div>
</form>
</body>我正在尝试工作小提琴:http://jsfiddle.net/92jv0erw/,但是弹出窗口并不是只显示在身体中的文本。
发布于 2016-09-27 11:16:18
根据评论和聊天,在最初发布的代码中有几个问题:
1)在原始代码中没有引用jQuery或jQuery UI。需要包括对这些脚本的引用。
2)试图设置对话框的JS代码在它引用的HTML元素存在之前运行--因为脚本在页面的上面,所以在浏览器中元素实际存在之前执行脚本,导致它失败。对此,最简单的解决方案是将脚本移动到HTML标记下面。因此,您应该将<script type="text/javascript">块及其所有内容移动到页面底部。一个合理的位置应该是在</form>和</body>结束标记之间。
https://stackoverflow.com/questions/39717934
复制相似问题