no message
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
document.getElementById('img').onclick=function(){
|
||||
alert("呵呵呵!")
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
+10
-3
@@ -6,19 +6,26 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>处理静态资源</title>
|
||||
<style>
|
||||
li{
|
||||
list-style: none;
|
||||
}
|
||||
.img{
|
||||
width: 1200px;
|
||||
/* height: 500px; */
|
||||
}
|
||||
.img img{
|
||||
width: 100%;
|
||||
width: 300px;
|
||||
/* height: 100%; */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>处理静态资源</h1>
|
||||
<li class="img"><img src="img.jpg" alt="" id="img"></li>
|
||||
<script src="click.js"></script>
|
||||
<li class="img"><img src="img.jpeg" alt="" id="img"></li>
|
||||
<script>
|
||||
document.getElementById('img').onclick=function(){
|
||||
alert("呵呵呵!")
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+3
-16
@@ -2,7 +2,7 @@ var http =require('http');
|
||||
var fs=require('fs');
|
||||
var server=http.createServer();
|
||||
server.on('request',function(req,res){
|
||||
// res.end('hello!');
|
||||
|
||||
var urls=req.url;
|
||||
if(urls=='/'){
|
||||
fs.readFile('./index.html',function(err,data){
|
||||
@@ -10,24 +10,11 @@ server.on('request',function(req,res){
|
||||
console.log(err)
|
||||
}
|
||||
else{
|
||||
res.writeHead(200, { 'content-type': 'text/html;charset=utf-8' });
|
||||
res.writeHead(200, { 'content-type': 'text/html;charset=utf-8'});
|
||||
res.end(data);
|
||||
}
|
||||
})
|
||||
}
|
||||
//挨个写入路由
|
||||
// else if(urls=='/img.jpg'){
|
||||
// fs.readFile('./img.jpg',function(err,data){
|
||||
// if(err){
|
||||
// console.log(err)
|
||||
// }
|
||||
// else{
|
||||
// res.writeHead(200, { 'content-type': 'text/html;charset=utf-8' });
|
||||
// res.end(data);
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//通用方法
|
||||
else{
|
||||
fs.readFile('.'+req.url,function(err,data){
|
||||
if(err){
|
||||
@@ -41,5 +28,5 @@ server.on('request',function(req,res){
|
||||
}
|
||||
})
|
||||
server.listen(8082,function(){
|
||||
console.log('8080端口启动成功!')
|
||||
console.log('8082端口启动成功!')
|
||||
})
|
||||
Reference in New Issue
Block a user