_______________________________________________________________________________
<script type="text/javascript">
<!--
function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != "none" ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}
function hide(){
document.getElementById("toggle").style.display='none';
}
//-->
</script>
<body onload="hide();">
<a onclick="switchMenu('toggle');" title="Test">Click Me</a><br><div id="toggle">This text toggles when Click Me is clicked.</div>
//实现对象的style动态的变化。document.getElementById("toggle").style.display='none';
-------------------------------------------------------------
<script type="text/javascript">
window.onload = function () {stinky.weirdnoise(); stinky.strangenoise();};
function Element(){
this.betterGetThatChecked = "prhraaappp bbloooop splaupp";
var badsound = "phhoooootttt";
this.weirdnoise = function () {
alert(badsound);
};
}
Element.prototype.strangenoise = function () {
alert(this.betterGetThatChecked);
};
stinky = new Element();
</script>
这个的功能不是标准的。在IE下可能无法使用,firefox下正常。(Prototyping on DOM elements does not work in IE. )
刚才看到一段非常经典的代码,给忘记抄下来
大意: createElement()link
link赋予属性链接到那个css文件;
link的其他编码属性等。
append进页面。
给现有或新建的Element赋值新来的css等。
=============思路之一:
var iframe = document.createElement("iframe");
iframe.id = TIMEOUT_IFRAME_ID;
iframe.name = TIMEOUT_IFRAME_NAME;
iframe.src = TIMEOUT_JSP + "?email=***@***.com+&nkey=15016236&initial=true&locale=zh_CN&twofa=false";
iframe.style.height = 0;
iframe.style.width = 0;
document.body.appendChild(iframe);
document.body.scroll = 'no';