<html>
<head>
<style>
#t1{
width:300px;
}
#t3{
width:300px;
}
</style>
<script>
window.onload=function(){
b.onclick=function(){
var s=t1.value;
var a=s.lastIndexOf("\\");
t2.value=s.substring(a+1);
}
b2.onclick=function(){
var s=t3.value;
var a=s.lastIndexOf("/");
t4.value=s.substring(a+1);
}
}
</script>
</head>
<body>
<input type="text" id="t1" value="D:\dev\Tomcat\webapps\ppp1\a.jsp"><br>
<input type="button" id="b" value="윈도우파일명" onclick=""><br>
<input type="text" id="t2">
<hr>
<input type="text" id="t3" value="/abc/def/b.java"><br>
<input type="button" id="b2" value="리눅스파일명"><br>
<input type="text" id="t4">
</body>
</html>
'개발하자 > 자바스크립트' 카테고리의 다른 글
css명령어 overflow : scroll | hidden | auto | visible (0) | 2015.02.17 |
---|---|
split()으로 구분자 잘라내어 새로운 문자첨가하기 (0) | 2015.02.17 |
문자열관련 메서드 (0) | 2015.02.17 |
첫문자는 대문자 나머지는 소문자로 바꾸기 (0) | 2015.02.17 |
split() (0) | 2015.02.17 |