[기초] 자바스크립트 페이지이동
2015.08.31 13:33
784
1
https://eond.com/361748
object(HotopayModel)#862 (23) { ["error"]=> int(0) ["message"]=> string(7) "success" ["variables"]=> array(0) { } ["httpStatusCode"]=> int(200) ["module"]=> string(7) "hotopay" ["module_info"]=> NULL ["origin_module_info"]=> NULL ["module_config"]=> NULL ["module_path"]=> string(52) "/home/eond/web/eond.com/public_html/modules/hotopay/" ["xml_info"]=> NULL ["module_srl"]=> NULL ["mid"]=> NULL ["act"]=> NULL ["template_path"]=> NULL ["template_file"]=> NULL ["layout_path"]=> NULL ["layout_file"]=> NULL ["edited_layout_file"]=> NULL ["stop_proc"]=> bool(false) ["user"]=> object(Rhymix\Framework\Helpers\SessionHelper)#861 (20) { ["member_srl"]=> int(0) ["user_id"]=> NULL ["user_name"]=> NULL ["nick_name"]=> NULL ["email_address"]=> NULL ["phone_number"]=> NULL ["homepage"]=> NULL ["blog"]=> NULL ["birthday"]=> NULL ["denied"]=> NULL ["status"]=> NULL ["is_admin"]=> string(1) "N" ["is_site_admin"]=> NULL ["profile_image"]=> NULL ["image_name"]=> NULL ["image_mark"]=> NULL ["signature"]=> NULL ["description"]=> NULL ["group_list"]=> array(0) { } ["menu_list"]=> array(0) { } } ["request"]=> object(Rhymix\Framework\Request)#10 (13) { ["method"]=> string(3) "GET" ["compat_method"]=> string(3) "GET" ["url"]=> string(32) "javascript/361748/comment/463804" ["hostname"]=> string(8) "eond.com" ["domain"]=> NULL ["protocol"]=> string(5) "https" ["callback_function"]=> string(0) "" ["_route_status":protected]=> int(200) ["_route_options":protected]=> object(stdClass)#11 (5) { ["cache_control"]=> bool(true) ["check_csrf"]=> bool(true) ["is_forwarded"]=> bool(false) ["is_indexable"]=> bool(true) ["enable_session"]=> bool(true) } ["module"]=> string(5) "board" ["mid"]=> string(10) "javascript" ["act"]=> string(16) "dispBoardContent" ["args"]=> array(5) { ["page"]=> int(2) ["document_srl"]=> string(6) "361748" ["comment_srl"]=> string(6) "463804" ["mid"]=> string(10) "javascript" ["act"]=> string(16) "dispBoardContent" } } ["ajaxRequestMethod"]=> array(2) { [0]=> string(6) "XMLRPC" [1]=> string(4) "JSON" } ["gzhandler_enable"]=> bool(true) }

<script type="text/javascript">
   location.replace("이동할 주소");         // 이동전 주소가 안보임. 
   location.href("이동할 주소");              // 이동전 주소가 보임
   history.go(-1);                                 // 이전페이지가기. ()안의 값이 현재페이지에 대한 상대좌표
   location.reload();                             // 새로고침
</script>

 

1. 자바스크립트로 페이지 이동

location.href="주소";

location.replace("주소");

어떤 메소드안에서 작업을 처리하고, 페이지를 넘기고 싶은 경우 location.href('경로');를 이용한다.
하지만 location.href 자동으로 페이지를 넘기는 경우. IE는 되지만 chrome에서는 되지않는다.

-> window.location.assign('경로')를 이용하면 된다.
-> window.location.replace('경로')도 크롬에서 적용된다.

하지만 이방법은 히스토리를 남기지 않기 때문에 뒤로가기가 되지않는다.

2. 타겟 지정하기

Window.location.href에서 target="_blank" 지정할 수 있습니다.

다음과 같이

var openNewWindow = window.open("about:blank");
openNewWindow.location.href = "main.html"

3. 몇 초 뒤에 이동시키기

3.1. setTimeout 함수 사용하기

setTimeout(function(){location.href='http://www.naver.com/';},3000); return false;

3.2. function(변수?) 으로 만들기

function move(){
location.href='http://eond.com';
}
setTimeout("move()", 3000);

4. 그 밖에 meta 코드를 이용하는 방법

<meta http-equiv="Refresh" Content="5;url=이동할 경로">

참조
http://blog.naver.com/rlarhdn66/220395886909
http://blog.naver.com/zxcvb8842?Redirect=Log&logNo=220355323591

라이믹스는 이온디와 함께

닫기

마이페이지

로그인을 해주세요

네이버로 로그인