onclick 링크걸기
<!-- 현재창에서 링크 이동 -->
<button type="button" onclick="location.href='링크주소';"> 버튼내용 </button>
<!-- 새 창으로 링크 이동 -->
<button type="button" onclick="window.open('링크주소');"> 버튼내용 </button>
출처: https://heinafantasy.com/110 [디지털 노마드:티스토리]
|
<!-- button 태그 -->
현재 페이지에서 다른 페이지으로 이동하기
<button onclick="location.href='index.html'">text</button >
새 페이지에서 다른 페이지 열기
<button onclick="window.open('index.html')">text</button >
현재 페이지 새로고침
<button onClick="location.reload();">text</button >
뒤로 가기
<button onClick="history.back();">text</button >
뒤로 1번 가기
<button onClick="history.go(-1);">text</button >
<!-- a 태그 -->
현재 페이지에서 다른 페이지으로 이동하기
<a href="#" onclick="location.href='index.html'">text</a>
새 페이지에서 다른 페이지 열기
<a href="#" onclick="window.open('index.html')">text</a>
현재 페이지 새로고침
<a href="#" onClick="location.reload();">text</a>
뒤로 가기
<a href="#" onClick="history.back();">text</a>
뒤로 1번 가기
<a href="#" onClick="history.go(-1);">text</a>
혹시나 history.back(), history.go(-1) 등 이 작동하지 않으면
return false;를 뒤쪽에 삽입하여 실행해 보세요.
<a href="#" onClick="history.go(-1);return false;">text</a>
|
'STUDY > 다스리는 개발병아리🐥' 카테고리의 다른 글
| 이클립스에서 html열기 (0) | 2022.11.19 |
|---|---|
| 2022_09_13 :버튼을 누르면 div내용 보였다가 안보였다가! (0) | 2022.09.13 |
| 2022_09_01 (0) | 2022.09.01 |
| 2022_08_31 (0) | 2022.08.31 |
| 2022_08_30 (0) | 2022.08.30 |