render()では任意のオブジェクトを指定できるので、あらかじめdivタグを用意しておけば、その中にパネルを表示することができます。サンプル02ではパネルを<div id="contents">
タグ内に表示しています。
サンプル02
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>YUIパネルサンプル</title>
<link rel="stylesheet" type="text/css" href="css/container.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<style type="text/css"><!--
#contents {
position:absolute;
top:200px;
left:100px;
width:500px;
height:300px;
background-color:gray;
}
--></style>
<script type="text/javascript" src="js/yahoo-dom-event.js"></script>
<script type="text/javascript" src="js/animation.js"></script>
<script type="text/javascript" src="js/dragdrop.js"></script>
<script type="text/javascript" src="js/container.js"></script>
<script type="text/javascript"><!--
window.onload = function() {
var panelObj = new YAHOO.widget.Panel("panel1");
panelObj.render(document.getElementById("contents"));
}
// --></script>
</head>
<body>
<h1>YUIパネルサンプル(基本)</h1>
<div id="panel1">
<div class="pHeader">■お知らせ</div>
<div class="pBody">ライブラリが新しいバージョンになりました。<br>
ダウンロードは以下のURLから。<br>
<a href="http://www.openspc2.org/">http://www.openspc2.org/</a>
</div>
<div class="pFooter">最終更新日 : 2007/7/21</div>
</div>
<div id="contents"></div>
</body>
</html>
パネルではタイトルバー部分にパネルのタイトルを指定することもできます(パネルヘッダー領域に設定されるわけではありません)。ダイアログのタイトルはsetHeader()メソッドで指定します。タイトルをパラメータとして指定します(サンプル03)。
サンプル03
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>YUIパネルサンプル</title>
<link rel="stylesheet" type="text/css" href="css/container.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<script type="text/javascript" src="js/yahoo-dom-event.js"></script>
<script type="text/javascript" src="js/animation.js"></script>
<script type="text/javascript" src="js/dragdrop.js"></script>
<script type="text/javascript" src="js/container.js"></script>
<script type="text/javascript"><!--
window.onload = function() {
var panelObj = new YAHOO.widget.Panel("panel1");
panelObj.setHeader(">Info");
panelObj.render();
}
// --></script>
</head>
<body>
<h1>YUIパネルサンプル(タイトル文字指定)</h1>
<div id="panel1">
<div class="pHeader">■お知らせ</div>
<div class="pBody">ライブラリが新しいバージョンになりました。<br>
ダウンロードは以下のURLから。<br>
<a href="http://www.openspc2.org/">http://www.openspc2.org/</a>
</div>
<div class="pFooter">最終更新日 : 2007/7/21</div>
</div>
</body>
</html>