发一小段代码,创建<div><iframe></div>用的.
代码就不用看了,散分贴!嘿嘿
<!doctype html public "-//w3c//dtd html 4.0 transitional//en ">
<html>
<head>
<title> CommonDiv </title>
<meta http-equiv= "Content-Type " content= "text/html; charset=UTF-8 ">
<script type= "text/javascript ">
<!--
//CommonDiv Object
function CommonDiv(parentObject){
this.unique = ((new Date()).valueOf()) % 604800000;
this.cDiv = null;
this.cIfrm = null;
this.cIfrmDoc = null;
this.init(parentObject);
}
CommonDiv.prototype.init = function (parentObject){
this.cDiv = document.createElement( "DIV ");
this.cIfrm = document.createElement( "IFRAME ");
this.cIfrm.frameBorder = "no ";
this.cDiv.appendChild(this.cIfrm);
try{
parentObject.appendChild(this.cDiv);
}catch(e){
throw new Error( "The parentObject is invalid! ");
}
this.cIfrmDoc = this.cIfrm.contentWindow.document;
this.cIfrmDoc.write( ' <html> <head> </head> <body> </body> </html> ');
this.cIfrmDoc.close();
}
//set the style of div
CommonDiv.prototype.setDivStyle = function (cssText){
this.cDiv.setAttribute( "id ", "comdiv " + this.unique);
var ss = new StyleSheet(document);
ss.insertRule( "#comdiv "+ this.unique,cssText);
}
//set the style of iframe
CommonDiv.prototype.setFrameStyle = function (cssText){
this.cIfrm.setAttribute( "id ", "comfrm " + this.unique);
var ss = new StyleSheet(document);
ss.insertRule( "#comfrm "+ this.unique,cssText);
}
//set the style of frame.documentElement
CommonDiv.prototype.setStyle = function (str){
var ss = new StyleSheet(this.cIfrmDoc);
//set the style of iframe.document here
//ss.insertRule( "body ", "background-color:#3399FF ",0);
}
//StyleSheet Object
function StyleSheet(doc){
this.sso = null;
this.createStyleSheet(doc);
}
StyleSheet.prototype.createStyle