에 관해서 질문드릴게 있습니다. 일단 제가 하고 싶은 건 입력칸에 test를 입력하고 버튼을 누르면

http://도메인.com/test.html 로 이동하는 기능을 구현하고 싶은데요. 일단 제가 아래 스크립트를 통해 test.html를 입력하면 해당 페이지로 이동하는 것까지는 성공을 했습니다. 

 

<script>
function doSomething() {
    // alert(document.forms[0].elements['name'].value);
    var url = document.forms[0].elements['name'].value;
    window.location = "http://도메인.co.kr/"+url;
    return false;
}
</script>
 

입력폼

 

<form onsubmit="return doSomething();" class="my-form">
    <input type="text" name="name">
    <input type="submit" value="Submit">
</form>

 

 

그런데 여기서, .html를 치지 않고도 test.html로 가는 방법이 있을까요? 도메인이 자동 입력된 것처럼 .html를 자동으로 입력시켜주는 기능이요... 혹시 가능할까요? .html까지 치지 않고 test만 쳐도 test.html페이지로 이동할 수 있게 하는 코드가 궁금합니다. 저 스크립트를 조금 수정하면 될 것 같은데 제가 생초보라 이런 것까지 막막하네요ㅠㅠ

 

 

 

  • profile
    window.location = "http://도메인.co.kr/"+url+".html";

    이면 되지 않을까요?
  • profile profile
    정말 감사합니다ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ