Nik*_*hil 2 javascript image relative-path src
在我写的小JavaScript中,'img'元素的'src'属性只有在我在图像的相对路径中将'\'更改为'/'时才接受并显示图像.
为什么会这样?
<html>
<body>
<img id="image" src="F:\wallpapers\other\black-and-white-lion-chess-hd-531078.jpg">
//why did '\' work here?
<script>
document.getElementById("image").src="F:/wallpapers/other/clouds_nature_skyscapes.jpg";
//why didn't '\' work here? Why did I have to use '/' ?
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4095 次 |
| 最近记录: |