发一小段代码,创建<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.createStyleSheet = function (doc){
//IE
if(doc.createStyleSheet)
this.sso = doc.createStyleSheet();
else{//FF
var styles = doc.getElementsByTagName( "HEAD ")[0].getElementsByTagName( "style ");
if(styles.length > 0)
this.sso = styles[styles.length-1];
else{
try{
this.sso=doc.createElement( "STYLE ");
this.sso.type= "text/css ";
doc.getElementsByTagName( "HEAD ")[0].appendChild(this.sso);
}catch(e){
this.sso = null;
}
}
}
}
StyleSheet.prototype.insertRule = function (selector,cssText){
if(this.sso.addRule)
this.sso.addRule(selector,cssText,this.sso.rules.length);
else if(this.sso.sheet)
this.sso.sheet.insertRule(selector + "{ " + cssText + "} ",this.sso.sheet.length);
}
//-->
</script>
</head>
<body>
<script type= "text/javascript ">
<!--
var cd = new CommonDiv(document.body);
cd.setDivStyle( "position:absolute; ");
cd.setDivStyle( "border:1px solid #FF6600; width:150px; left:100px; ");
cd.setDivStyle( "height:220px; top:100px; ");
cd.setFrameStyle( "width:100%; height:100%; border:0px; ");
var ss = document.getElementsByTagName( "head ")[0].getElementsByTagName( "style ");
//prompt( " ",document.getElementsByTagName( "head ")[0].innerHTML.replace(/\n/g, " "));
//-->
</script>
</body>
</html>
[解决办法]
沙~~~~~~~~~~~~~
发
[解决办法]
就一框什用的?
[解决办法]
接分! ^_^
[解决办法]
拿分
[解决办法]
JF
------解决方案--------------------
一段设置CSS的代码,:)
[解决办法]
嘿嘿。。接分先。。
[解决办法]
顶
[解决办法]
对这个不熟悉。。
我看石头君是这样写的。
(function () {
if (window.CSSStyleSheet) {
CSSStyleSheet.prototype.addRule = function (a, b) {
var wc = this;
wc.insertRule(a + "{ " + b + "} ", wc.cssRules.length);
};
})();
这些有什么基本的区别?
[解决办法]
一样的,兼容FF的。
[解决办法]
接分,学习
[解决办法]
一个框不需要这么多代码吧
[解决办法]
学习,JF
[解决办法]
昂。。完全了解了的说。。
嘿嘿。。
this.sso.sheet.length是undefined
this.sso.sheet.cssRules.length有值
[解决办法]
jf
学习
[解决办法]
学习,JF
[解决办法]
j~~~~~~~~~~~~~F
了
[解决办法]
命名没有参数命名法...鉴定完毕...
可以接分么...
[解决办法]
JF~~~~~~~~~~~~~~~~~~````````````````
[解决办法]
JF~~~~~~~~~~~~~~~~~~````````````````
[解决办法]
xx!
学习学习!
[解决办法]
接分,学习
[解决办法]
接分,学习
[解决办法]
....?
还是接分了
[解决办法]
learn ~~~up~~
[解决办法]
jf
[解决办法]
才疏学浅,看不太懂:(
[解决办法]
jf
[解决办法]
能不能说一下用来做什么的?
[解决办法]
学习
[解决办法]
study
[解决办法]
谢谢~~以后需要一个框框开发就方便哒~~哈~~
[解决办法]
哇, 这个也许对我有用呀...
最近在弄一个UI库...就是集成一堆预定的效果...
[解决办法]
忽忽。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> CommonDiv </title>
<style type= "text/css ">
html {
background-color:#000000;
}
</style>
<script type= "text/javascript ">
(function () {
if (window.CSSStyleSheet) {
var wc = window.CSSStyleSheet.prototype;
wc.addRule = function (a, b) {
var wc = this;
wc.insertRule(a + "{ " + b + "} ", wc.cssRules.length);
};
wc.removeRule = function (a) {
var wc = this;
wc.deleteRule(a);
};
wc.__defineGetter__( "rules ", new Function( "return this.cssRules "));
}
})();
var wc = document.styleSheets[0];
alert(wc.rules[0].selectorText + ": " + wc.rules[0].style.cssText);
wc.removeRule(0);
</script>
</body>
</html>
[解决办法]
prototype
[解决办法]
接分
[解决办法]
jf
[解决办法]
占个坑再看
[解决办法]
jf
[解决办法]
俺用代码灌水..
shawl.qiu framework javascript client-side
---/------------------------------------------
目录:
1. 调用(注意, 如果调用不是放在 onload 事件里, 则必须放在结束标签的后面, 要不然会出错)
1.1 调用1
---/--------------------------------------
内容:
1.1 调用1
<style type= "text/css ">
/* <![CDATA[ */
.sqCoupletMainClassName
{
white-space: pre; /* CSS2 */
white-space: -moz-pre-wrap; /* Mozilla */
white-space: -hp-pre-wrap; /* HP printers */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: pre-wrap; /* CSS 2.1 */
white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
word-wrap: break-word; /* IE */
background-color:white;
}
.sqCoupletCloseBtn
{
text-align:right;
border:4px solid #E0E0E0;
}
.sqCoupletCloseBtn span
{
padding:2px 5px;
}
.sqCoupletTextClassName
{
border:5px solid #E0E0E0;
margin:2px 0px;
padding:2px;
text-align:center;
}
/* ]]> */
</style>
<script type= "text/javascript ">
// <![CDATA[
/*----------------UI---------------------*/
//im.go( 'UI.Rounded ');
//im.help( 'UI.Rounded ', true);
//-
im.go( 'UI.Couplet ');
//im.help( 'UI.Couplet ', true);
//]]>
</script>
<script type= "text/javascript ">
// <![CDATA[
var cpl = new Couplet();
cpl.Go();
cpl = null;
//]]>
</script>
2. 类 Couplet
// shawl.qiu JavaScript Document
/*-----------------------------------------------*\
* shawl.qiu javascript Couplet class v1.0
\*-----------------------------------------------*/
//---------------------------------begin class Couplet()-------------------------------//
function Couplet()
{ // shawl.qiu code
//------------------------------------begin public variable
//---------------begin about
this.auSubject = 'shawl.qiu javascript Couplet class ';
this.auVersion = 'v1.0 ';
this.au = 'shawl.qiu ';
this.auEmail = 'shawl.qiu@gmail.com ';
this.auBlog = 'http://blog.csdn.net/btbtd ';
this.auCreateDate = '2007-5-16 ';
//---------------end about
this.OffsetWidth = 110;
this.OffsetTop = 60;
this.OffsetLeft = 5;
this.OffsetRight = 5;
this.ClassName = {};
this.ClassName.Main = "sqCoupletMainClassName ";
this.ClassName.Text = "sqCoupletTextClassName "
this.Closer = {};
this.Closer.Class = {};
this.Closer.Class.Name = "sqCoupletCloseBtn ";
this.Closer.Go = fCloserGo;
this.LeftPart = {};
this.LeftPart.ID = "sqCoupletLeftPart ";
this.LeftPart.Text = {};
this.LeftPart.Text.ID = "sqCoupletLeftPartTextId ";
this.LeftPart.Text.InnerHtml = "test............\r\n.............\r\n.............\r\n........... ";
this.RightPart = {};
this.RightPart.ID = "sqCoupletRightPart ";
this.RightPart.Text = {};
this.RightPart.Text.ID = "sqCoupletRightPartTextId ";
this.RightPart.Text.InnerHtml = "test............\r\n.............\r\n.............\r\n........... ";
this.Count = 1;
//------------------------------------end public variable
//------------------------------------begin private variable
var Tl = this;
var pLeftPart = null;
var pRightPart = null;
//------------------------------------end private variable
//------------------------------------begin public method
this.Go = fGo;
//------------------------------------end public method
//------------------------------------begin private method
function fGo()
{
/* start left part */
var EleDivLeft = document.createElement( "div ");
EleDivLeft.id = Tl.LeftPart.ID;
EleDivLeft.className = Tl.ClassName.Main;
with(EleDivLeft.style)
{
if(fCkBrs()!=1)
{
position = "fixed ";
}
else
{
position = "absolute ";
}
left = Tl.OffsetLeft+ "px ";
top = Tl.OffsetTop+ "px ";
width = Tl.OffsetWidth+ "px ";
} // end with
document.body.appendChild(EleDivLeft);
pLeftPart = document.getElementById(Tl.LeftPart.ID);
var CloseSpan = document.createElement( "span ");
CloseSpan.innerHTML = "X ";
CloseSpan.onclick = Tl.Closer.Go;
var EleCloseLeft = document.createElement( "div ");
EleCloseLeft.className = Tl.Closer.Class.Name;
EleCloseLeft.appendChild(CloseSpan);
var EleLeftPartText = document.createElement( "div ");
with(EleLeftPartText)
{
id = Tl.LeftPart.Text.ID;
className = Tl.ClassName.Text;
innerHTML = Tl.LeftPart.Text.InnerHtml;
}
pLeftPart.insertBefore(EleCloseLeft, pLeftPart.firstChild);
pLeftPart.appendChild(EleLeftPartText);
/* end left part */
/* start right part */
var EleDivRight = document.createElement( "div ");
EleDivRight.id = Tl.RightPart.ID;
EleDivRight.className = Tl.ClassName.Main;
with(EleDivRight.style)
{
if(fCkBrs()!=1)
{
position = "fixed ";
}
else
{
position = "absolute ";
}
right = Tl.OffsetRight+ "px ";
top = Tl.OffsetTop+ "px ";
width = Tl.OffsetWidth+ "px ";
} // end with
document.body.appendChild(EleDivRight);
pRightPart = document.getElementById(Tl.RightPart.ID);
var CloseSpan = document.createElement( "span ");
CloseSpan.innerHTML = "X ";
CloseSpan.onclick = Tl.Closer.Go;
var EleCloseRight = document.createElement( "div ");
EleCloseRight.className = Tl.Closer.Class.Name;
EleCloseRight.appendChild(CloseSpan);
var EleRightPartText = document.createElement( "div ");
with(EleRightPartText)
{
id = Tl.RightPart.Text.ID;
className = Tl.ClassName.Text;
innerHTML = Tl.RightPart.Text.InnerHtml;
}
pRightPart.insertBefore(EleCloseRight, pRightPart.firstChild);
pRightPart.appendChild(EleRightPartText);
/* end right part */
if(fCkBrs()==1)
{
onscroll = fScrollForIe;
}
} // end function fGo
function fCloserGo()
{
var bCfm = confirm( '现在关闭对联吗? ');
if(bCfm)
{
if(pLeftPart!=null)
{
pLeftPart.style.display = "none ";
}
if(pRightPart != null)
{
pRightPart.style.display = "none ";
}
}
} // end function fCloserGo
function fScrollForIe()
{
if(pLeftPart!=null)
{
pLeftPart.style.top = document.documentElement.scrollTop + Tl.OffsetTop+ "px ";
}
if(pRightPart!=null)
{
pRightPart.style.top = document.documentElement.scrollTop + Tl.OffsetTop+ "px ";
}
} // end function fScrollForIe
function fCkBrs()
{
switch (navigator.appName)
{
case 'Opera ': return 2;
case 'Netscape ': return 3;
default: return 1;
}
} // end function fCkBrs
function fInsertNode(OldNode, NewNode, bBefore)
{// shawl.qiu script
var ParentNode = OldNode.parentNode;
if(!ParentNode)return false;
if(bBefore)
{
ParentNode.insertBefore(NewNode,OldNode);
return false;
} // end if
ParentNode.replaceChild(NewNode, OldNode);
ParentNode.insertBefore(OldNode, NewNode);
} // end function fInsertNode
//------------------------------------end private method
} // shawl.qiu code
//---------------------------------end class Couplet()---------------------------------//
var couplet = new Couplet();
[解决办法]
帮顶。
[解决办法]
帮顶
[解决办法]
嘿嘿
[解决办法]
嘿嘿。。接分先。。
[解决办法]
....
[解决办法]
jf
[解决办法]
接分先。哈。。。。
------解决方案--------------------
JF
[解决办法]
接分! ^_^
[解决办法]
接分
[解决办法]
多接点分
[解决办法]
学习
[解决办法]
希望以后多帮大家解决问题!~
[解决办法]
学习,接分
[解决办法]
谢谢。