码迷,mamicode.com
首页 > 其他好文 > 详细

相对路径的问题

时间:2017-05-24 11:10:39      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:cli   min   路径   top   http   file   text   har   load   

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script>
window.onload = function (){
var oImg = document.getElementById(‘img1‘);

oImg.onclick = function (){
// alert( oImg.src );
// img/1.jpg
// file:///C:/Users/Administrator/Desktop/11-4-JS1/img/1.jpg
// if( oImg.src == ‘img/1.jpg‘ ){
// 不能做为判断条件:

// 1、所有的相对路径地址
/*
img src
href

2、颜色值:color: red #f00 rgb() rgba()
*/

if( oImg.src == ‘file:///C:/Users/Administrator/Desktop/11-4-JS1/img/1.jpg‘ ){
oImg.src = ‘img/2.jpg‘;
}
};
};
</script>
</head>

<body>

<img id="img1" src="img/1.jpg" width="400" />

</body>
</html>

相对路径的问题

标签:cli   min   路径   top   http   file   text   har   load   

原文地址:http://www.cnblogs.com/zhousha929-/p/6897756.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!