【发布时间】:2017-02-23 10:37:31
【问题描述】:
我的主页里面有 4 个 iframe。
MainPage.html
<html>
<head>
<title>My alert</title>
<script src="jquery-1.12.4.js"></script>
<script src="jquery-ui.js"></script>
<script src="custom-alert.js"></script>
<link rel="stylesheet" href="jquery-ui.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="mainPage" style="text-align:center;">
<h1>Main Page</h1>
<input type="button" value="Trigger" onclick="$.alert('This is test msg', 'My Title');" /><br/><br/>
<div id="page1"><iframe id="if1" src="page1.html"></iframe></div>
<div id="page2"><iframe id="if2" src="page2.html"></iframe></div>
<div id="page3"><iframe id="if3" src="page3.html"></iframe></div>
<div id="page4"><iframe id="if4" src="page4.html"></iframe></div>
</div>
</body>
</html>
我想在屏幕中心显示 jquery 对话框,而不考虑 iframe..
custom-alert.js
$.extend({
alert: function (message, title) {
$("<div></div>").dialog({
buttons: { "Ok": function () { $(this).dialog("close"); } },
close: function (event, ui) { $(this).remove(); },
resizable: false,
draggable: false,
title: title,
modal: true
}).text(message);
}
});
page1.html 到 page4.html 如下
<html>
<head>
<title>My alert</title>
<!-- Include there four files as MIME Object -->
<!-- call using $.alert("message", "title") -->
<script src="jquery-1.12.4.js"></script>
<script src="jquery-ui.js"></script>
<script src="custom-alert.js"></script>
<link rel="stylesheet" href="jquery-ui.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<input type="button" value="Trigger" onclick="$.alert('This is test msg 1', 'My Title');" /><br/><br/>
</body>
</html>
如何将对话框置于屏幕中心而不是页面中心?
【问题讨论】:
标签: javascript jquery html css iframe