if (window.addEventListener) { window.addEventListener ("message", receiveSize, false); window.addEventListener ("resize", receiveCallAnchor, false); } else if (window.attachEvent) { window.attachEvent("onmessage", receiveSize); window.attachEvent("onresize", receiveCallAnchor); } function appoint_init(add_element) { var base_url = ""; base_url += "https://www.carbase.jp/"; base_url += "api/index_ref.html?limit=20"; base_url += "&sort=rand"; base_url += "&disp_mode="; base_url += "&client_no="; base_url += "&shashu_no="; base_url += "&maker_no=15"; base_url += "&category_no="; base_url += "&special_no="; base_url += "&ex_dough_flag=4"; base_url += "&key="; base_url += "&element_id=" + add_element; document.getElementById(add_element).innerHTML = ""; document.getElementById('id_prev').src = base_url; } function receiveCallAnchor(){ var response = "width:" + document.body.clientWidth; document.getElementById("id_prev").contentWindow.postMessage(response,"*"); } function receiveSize(e) { var cStr = e.data; if ( cStr == "request_close" ) { $.prettyPhoto.close(); return; } var sp = ""; var UA = navigator.userAgent; if ( (UA.indexOf('iPhone') !== -1)//iphone‚©A || ((UA.indexOf('Android') !== -1) && (UA.indexOf('Mobile') !== -1)) || (UA.indexOf('Windows Phone') !== -1) || (UA.indexOf('BlackBerry') !== -1) || (UA.indexOf('iPad') !== -1) ) { sp = "1"; }; if( cStr.indexOf("frame_height") != "-1"){ var frame_height = cStr.replace("frame_height", ""); document.getElementById("id_prev").style.height = frame_height + "px"; receiveCallAnchor(); } if( cStr.indexOf("car_no") != "-1"){ $.fn.prettyPhoto(); var car_no = cStr.replace("car_no_", ""); // if( document.body.clientWidth < 1000 || sp == "1" ){ if( sp == "1" ){ // var detail_url = "https://www.carbase.jp/api/sp_details_ref.html?car_no=" + car_no + "&screen_width=" + document.body.clientWidth + "&pc=0"; // location.href = detail_url; //window.open(detail_url, "_blank"); } else { if( document.body.clientWidth < 950 ) { // var detail_url = "https://www.carbase.jp/api/details_ref.html?car_no=" + car_no + "&screen_width=" + document.body.clientWidth + "&pc=1"; // location.href = detail_url; //window.open(detail_url, "_blank"); } else { $.prettyPhoto.open('https://www.carbase.jp/api/details_ref.html?car_no=' + car_no + '&screen_width=' + document.body.clientWidth + "&pc=1" + '&iframe=true&width=945&height=100%','',''); return false; } } } /* if ( cStr.indexOf("scroll_to_top") != "-1"){ this.scrollTo(0,0); } */ }