我在帮助文档里只找到了这样的代码:
var myPopup = window.createPopup();
var popupBody = myPopup.document.body;
popupBody.style.backgroundColor = "#ffff99 ";
如果我想将style.css文件附加到这个pop-window上,js怎么写啊?
------解决方案--------------------
function SetMxxCalendarStyle(){
var oStyleSheet=oPopup.document.createStyleSheet();
with(oStyleSheet){
addRule( "td ", "vertical-align:middle; text-align: center; border:1px solid; border-color: #D4D0C8 #FFFFFF #FFFFFF #D4D0C8 ");
addRule( "#tbMxxCalendar ", "border:solid 1px #6BBFD9; font-size:12px; width:100%; height:100%; cursor:default ");
addRule( ".button ", "width:100%; height:100%;border: 0px solid #D4D0C8; padding-top: 1px; height: 18;color:#000080; background-color:#FFFFF1 ");
addRule( ".firstrow ", "color:#000080; background-color:#FFFFF1 ");
addRule( ".secondrow ", "color:blue; background-color:#FFFFF1 ");
addRule( ".curMonth ", "color:#000080; background-color:#DEEAF6 ");
addRule( ".notCurMonth ", "color:#DCDCDC; background-color:#DEEAF6 ");
addRule( ".curDay ", "color:red; background-color:#DEEAF6 ");
addRule( ".tdTime ", "color:#FF00FF; background-color:#FFFFF1 ");
addRule( ".tdOver ", "color:#FFFFF1; background-color:#6BBFD9 ");
addRule( ".tdWeek ", "color:#3399FF; background-color:#FFFFF1 ");
}
var tbRows = oPopup.document.getElementById( "tbMxxCalendar ").rows;
tbRows[0].className = "firstrow ";
tbRows[1].className = "secondrow ";
for(var i=2;i <8;i++){
tbRows[i].cells[0].className = "tdWeek ";
}
}
------解决方案--------------------
<html>
<head>
<meta http-equiv= "content-type " content= "text/html; charset=UTF-8 "/>
<script type= "text/javascript ">
<!--
function addCss(){
var oStyleSheet = document.createStyleSheet( "css.css ",0);
}
//-->
</script>
<body>
<input type= "button " value= "Click me to add css " onclick= "addCss() ">
</body>
</html>