|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
归根到底,Java跨平台可以,但是要重新编写代码,否则还分什么J2EE/J2SE/J2ME呢!ThefirstcodesnippetbelowusestheAttributescollectionofthe<body>tag(implementedasanHtmlControlobject)toreferenceitsstandardHTMLattributes.ThismethodgivesyouprogrammaticaccesstoanyoftheHTMLattributesthatyounormallyhard-codeintoyour<body>tag.
ThesecondmethodusestheStyleobjectpropertyoftheHtmlControlobject.BymakingcallstotheStyleobjectpropertysAddmethod,youcanaddcustomstylestoyour<body>tag.Theseareimplementedasaninlinestyletagwhenitisrenderedtothebrowser.
Becauseofthis,youmaywanttoresearchwhetherthestyleyouaregoingtoimplementiscompatiblewiththebrowseryouaretargeting.
ThetechniquesusedherecanbeusedtosetthepropertiesofanyHTMLcontrolthatdoesnothaveaServerControlequivalent.Anexamplewouldbethe<p>tag.
Samplecode1:Usethe"Attributes"collectionofthebodytag
<%@PageLanguage="C#"%>
<scriptlanguage="C#"runat="server">
protectedvoidPage_Load(objectsender,EventArgse){
body.Attributes["BgColor"]="#CCCCCC";
}
</script>
<bodyid="body"runat="server">
Thisisthebodytext.
</body>
SampleCode2:Usethe"Style"collectionofthebodytag
<%@PageLanguage="C#"%>
<scriptlanguage="C#"runat="server">
protectedvoidPage_Load(objectsender,EventArgse){
body.Style.Add("background-color","#CCCCCC");
}
</script>
<bodyid="body"runat="server">
Thisisthebodytext.
</body>
Notes:
Besuretoaddtherunat="server"attributetoyourbodytagandgiveitanID
[img=1border=0style=,1src=]http://www.ckuyun.com/[/img]
如果需要重新编写代码,几乎任何一门计算机语言都可以跨平台了,还用得着Java嘛,而且像PHP/C#等语言不需要修改代码都可以跨Windows/Linux。 |
|