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.html?client_no=53015"; base_url += "&shashu_no="; base_url += "&maker_no="; base_url += "&disp_mode="; base_url += "&category_no="; base_url += "&special_no="; base_url += "&ex_dough_flag="; base_url += "&key="; base_url += "&min_kakaku="; base_url += "&max_kakaku="; base_url += "&limit="; base_url += "&bg_color=444"; base_url += "&bg_color2=444"; 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; 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/car/detail_API.php?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/car/detail_API.php?car_no=" + car_no + "&screen_width=" + document.body.clientWidth + "&pc=1"; location.href = detail_url; //window.open(detail_url, "_blank"); // } else { // var date = new Date(); // $.prettyPhoto.open('https://www.carbase.jp/api/details.html?car_no=' + car_no + '&screen_width=' + document.body.clientWidth + "&pc=1&v=" + date.getTime() + '&iframe=true&width=945&height=100%','',''); // } } } if ( cStr.indexOf("scroll_to_top") != "-1"){ this.scrollTo(0,0); } }