window.addEventListener("message", receiveRun, false); function receiveRun(e) { switch(e.origin){ case "https://www.bengoshi-kokoro.com": case "https://www.kokoro-news.com": console.log(e.data); const topUrl = $(".foot_ttl a").attr("href"); if (Array.isArray(e.data)) {//iframe高さ値の処理(複数) window.scroll(0,0); for (const [key, value] of Object.entries(e.data)) { const idName = `${key}_if`; const ifHight = `${value}`; document.getElementById(idName).style.height = ifHight + "px"; } }else if (e.data.charAt(0) === "s") {//アンカーリンクスクロール値の処理 const ifScroll = Number(e.data.slice(1)); const ifHeight = $("#main_if").offset().top ; const navHeight = $(".nav").height(); const topSpace = ($(window).width() < 600) ? $(window).width() * 0.04 : 15; const scrollposition = ifHeight + ifScroll - navHeight - topSpace; $("html, body").animate({scrollTop:scrollposition}, 500, "linear"); }else if (e.data.charAt(0) === "h") {//iframe高さ値の処理 window.scroll(0,0); document.getElementById("main_if").style.height = e.data.slice(1) + "px"; }else if (e.data.charAt(0) === "r") {//iframe高さ値取得の再処理(アコーディオン開閉時) document.getElementById("main_if").style.height = e.data.slice(1) + "px"; }else if (e.data.charAt(0) === "c") {//iframe高さ値取得の再処理と親ページのurl再送信(カテゴリ選択時) document.getElementById("main_if").style.height = e.data.slice(1) + "px";//iframe高さ値取得の再処理 sendParenturl();//mediainfo、massmediaページの場合url再送信(カテゴリ選択時) }else if (e.data.charAt(0) === "a") { if(location.href.indexOf("/access/")!== -1){//アクセスページの時、別インラインフレーム内スクロール const id = e.data.slice(2); const win = document.getElementById("main_if").contentWindow; win.postMessage(id,"*"); }else{//アクセスページへ移動し、スクロール window.location.href = topUrl + "access/?" + e.data.slice(2); } }else if (e.data.charAt(0) === "b") {//iframe高さ値取得の再処理(複数) const resendHeight = e.data.slice(1).split("="); const idName = resendHeight[0]; const ifHight = resendHeight[1]; document.getElementById(idName + "_if").style.height = ifHight + "px"; }else if (e.data.charAt(0) === "d") {//エリアマップアンカーリンクスクロール値の処理 const idHeight = e.data.slice(1).split("&"); const idName = idHeight[0]; const ifScroll = Number(idHeight[1]); const ifHeight = $(idName + "_if").offset().top; const navHeight = $(".nav").height(); const topSpace = ($(window).width() < 600) ? $(window).width() * 0.04 : 15; const scrollposition = ifHeight + ifScroll - navHeight - topSpace; $("html, body").animate({scrollTop:scrollposition}, 500, "linear"); }else if (e.data.charAt(0) === "e") {//インラインフレーム内からインラインフレーム外アンカーリンクへのスクロール処理 const id = e.data.slice(1); const ifHeight = $(id).offset().top; const navHeight = $(".nav").height(); const topSpace = ($(window).width() < 600) ? $(window).width() * 0.04 : 15; const scrollposition = ifHeight - navHeight - topSpace; $("html, body").animate({scrollTop:scrollposition}, 500, "linear"); }else if (e.data.charAt(0) === "f") {//トップページへ移動し、スクロール(事務所のへの行き方ボタン) window.location.href = topUrl + e.data.slice(1); }else if (e.data.charAt(0) === "g") {//インラインフレームのスクロールid送信(複数) const sendId = e.data.slice(1).split("&"); const id = sendId[0]; const idName = sendId[1]; const win = document.getElementById(idName + "_if").contentWindow; win.postMessage( id + "&mif&" + idName,"*"); }else if (e.data.charAt(0) === "i") {//インラインフレームのスクロール処理(複数) const idHeight = e.data.slice(1).split("&"); const idName = idHeight[0]; const ifScroll = Number(idHeight[1]); const ifHeight = $("#" + idName + "_if").offset().top; const navHeight = $(".nav").height(); const topSpace = ($(window).width() < 600) ? $(window).width() * 0.04 : 15; const scrollposition = ifHeight + ifScroll - navHeight - topSpace; $("html, body").animate({scrollTop:scrollposition}, 500, "linear"); } break; } } function sendParenturl() {//mediainfo、massmediaページの場合url送信 var parentUrl = location.href; var regexp = /mediainfo|massmedia/; if(regexp.test(parentUrl)){ var win = document.getElementById("main_if").contentWindow; win.postMessage("pu," + parentUrl,"*"); } } //データ送信用 $(window).on("load",function(){ sendParenturl();//mediainfo、massmediaページの場合url送信 if( 1 < window.location.search.length ){//?以下のid送信 const id = window.location.search.substring(1); if(location.href.indexOf("/staff/")!== -1){ const idName = id === "staff"?"clerk":"expert"; const win = document.getElementById(idName + "_if").contentWindow; win.postMessage( "#"+ id + "&mif&" + idName,"*"); }else{ const win = document.getElementById("main_if").contentWindow; win.postMessage(id,"*"); } } }); //選ばれる理由アコーディオン $(function(){ $('.riyuuttl_list .continue_btn,.kouishougaishinsei_sec .continue_btn').append(''); $('.riyuuttl_list .riyuu_on,.kouishougaishinsei_sec .acd_on').hide(); $('.riyuuttl_list .continue_btn,.kouishougaishinsei_sec .continue_btn').click(function(){ var navHeight = $('.nav').height(); var topSpace = ($(window).width() < 600) ? $(window).width() * 0.04 : 15; var offsetTop = $(this).parent().offset().top - navHeight - topSpace; if($(window).scrollTop() > offsetTop) { $('html,body').animate({scrollTop:offsetTop}, 500); $(this).prev().delay(400).slideToggle(); } else { $(this).prev().slideToggle(); } }); }); //解決実績アコーディオン $(function(){ /*$('.jisseki_close').append('');*/ $('.jisseki_sec .acd_on').hide(); $('.jisseki_sec .acd_off').click(function(){ $(this).slideToggle(); $(this).prev().slideToggle(); }); $('.jisseki_sec .jisseki_close').click(function(){ if($(this).hasClass('ttl_close')){ $(this).parent().slideToggle(); $(this).parent().next().slideToggle(); } else { var navHeight = $('.nav').height(); var topSpace = ($(window).width() < 600) ? $(window).width() * 0.04 : 15; var offsetTop = $(this).parent().parent().offset().top - navHeight - topSpace; if($(window).scrollTop() > offsetTop) { $('html,body').animate({scrollTop:offsetTop}, 500); $(this).parent().delay(400).slideToggle(); $(this).parent().next().delay(400).slideToggle(); }else{ $(this).parent().slideToggle(); $(this).parent().next().slideToggle(); } } }); }); $(function(){ $('.main_cat p.m_ttl').removeClass('toggle_btn'); $('.main_cat p.m_ttl i').remove(); });