본문 바로가기

webdesign/HTML

location.href=, onClick=""

1. 현재페이지에 부를때
onclick="location.href='m01_main.html'"

1-1. 새 창에 열때
onclick="window.open('http://www.yunsoo.com')"

2. 상위 프레임에 부를때
onclick="parent.location.href='m01_main.html'"
 

3. 현재 페이지와 같은 레벨의 프레임에 불러올때
onclick="parent.프레임네임.location.href='m01_main.html'"

(parent 없이  프레임네임으로 부르면 오류)

4. 아이프레임에 불러올때

onclick="document.getElementById('프레임네임).src='m01_main.html'"

또는

<script language="JavaScript">
 function chUrl() {

   document.getElementById('i_frame').src = "http://kr.yahoo.com"

 }

</script>


<span onclick="chUrl">경로변경</span>

<iframe id="i_frame" src="1.html" width="300" height="300"></iframe>


또는

window.open("주소", "아이프레임이름");

5. 상단, 좌측, 바디의 세 개 프레임으로 이루어진 화면에서
탑프레임에서 좌측과 바디부분의 프레임에 다른 문서 불러오기
onclick="parent.MainFrame.location.href='m01_main.html';parent.leftFrame.location.href='left_menu.html';"


 ex2)
상단 탑메뉴 html 하나로 좌측 메뉴 파일과 우측 바디파일 여러개를 사용할때
클릭시 상단 메뉴 롤오버 이미지 적용과 함께 좌측  메뉴 파일, 우측 바디파일 불러오기
onclick="parent.MainFrame.location.href='m01_main.html';parent.leftFrame.location.href='left_menu.html';
               document.getElementById('m07').src='../images/top/m07_on.gif';"