html5中全屏API |
html5, javascript |
5个不可错过的HTML 5中的API |
function launchFullScreen(element) {
if(element.requestFullScreen) {
element.requestFullScreen();
} else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if(element.webkitRequestFullScreen) {
element.webkitRequestFullScreen();
}
}
// Launch fullscreen for browsers that support it!
launchFullScreen(document.documentElement);
launchFullScreen(document.getElementById("videoElement")); //点单独的与元素时启动
|
C++多态 |
c++, 多态 |
c++多态性 |
<span style="font-size: small;"><span style="font-size: small;">#include <iostream.h>
class Animal
{
public:
void eat(){
cout << "animal eat" << endl;
}
void sleep(){
cout << "animal sleep" << endl;
}
virtual void breathe(){
cout << "animal breathe" << endl;
}
};
class Fish : public Animal
{
public:
void sleep(){
cout << "fish sleep" << endl;
}
void breathe(){
cout << "fish breathe" << endl;
}
};
void main()
{
Animal an;
Fish fs;
Animal *p = &an;
p -> sleep();
p -> breathe();
p = &fs;
p -> sleep();
p -> breathe();
Fish *p = (Fish *)&an;
p -> sleep();
p -> breathe();
}
animal sleep
animal breathe
animal sleep
fish breathe
fish sleep
animal breathe
</span></span>
|
Java this |
this, java |
JAVA中让人容易混淆的this总结(未完待续) |
public class A(){
public String str="bbb";
public A(String str){
sysout.out.println(str);
sysout.out.println(this.str);
}
}
|
JAVA类抓取IP地址 |
java, net, ip |
JAVA类抓取IP地址 |
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;
public class IPAddrFetcher {
public static String getIPInfo() {
String trueIp = null;
try {
Enumeration interfaces = NetworkInterface
.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
NetworkInterface ni = interfaces.nextElement();
Enumeration inetAddresses = ni.getInetAddresses();
while (inetAddresses.hasMoreElements()) {
InetAddress address = inetAddresses.nextElement();
if (address instanceof Inet4Address) {
if (!address.getHostAddress().equals("127.0.0.1"))
trueIp = address.getHostAddress();
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return trueIp;
}
}
|
教你一招让你的IE 6/7/8/9/x都支持HTML5 |
html5, 浏览器 |
教你一招让你的IE 6/7/8/9/x都支持HTML5 |
解决办法就是使用HTML5 shiv,而HTML5 Shiv其实就是一个Javacsript脚本。
<!–[if IE]>
<script src=”http://html5shiv.googlecode.com/svn/trunk/html5.js”>
</script>
<![endif]–>
|