HTML-버튼에 링크 거는 방법

HTML-버튼에 링크 거는 방법

HTML

1
2
3
<form action="http://google.com">
<input type="submit" value="Go to Google" />
</form>

<input type="submit"/> 말고도 <button type="submit">를 사용할 수도 있습니다.

CSS

css를 사용할 수 있다면, <a>태그를 사용해서 버튼 모양처럼 변경할 수 있습니다.

1
<a href="http://google.com" class="button">Go to Google</a>
1
2
3
4
5
6
7
8
a.button {
-webkit-appearance: button;
-moz-appearance: button;
appearance: button;

text-decoration: none;
color: initial;
}

JavaScript

자바스크립트를 사용할 수 있다면 아래와 같이 사용하면 됩니다.

1
2
3
4
5
6
7
8
//현재 탭으로 열기
<input type="button" onclick="location.href='http://google.com';" value="Go to Google" />

//새로운 탭으로 열기
<input type="button" value="버튼" onClick="window.open('http://google.com')">

//jsp를 이용할 경우
<button type="button" onclick="location.href='joinUs.jsp'">회원가입</button>
Reference
Share