JS DOM推荐forum-CarlZeng

JS DOM推荐forum(www.webmasterworld.com/javascript/)

_______________________________________________________________________________Click MeThis text toggles when Click Me is clicked.//实现对象的style动态的变化。document.getElementById(“toggle”).style.display=’non…
_______________________________________________________________________________

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<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’;
-————————————————————

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<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等。

=============思路之一:

1
2
3
4
5
6
7
8
9
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](mailto:?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';

个性化需求沟通 扫客服加V加群: