/** * Created by wangxj on 2017/7/18. */ var frame_height = $(window).height() - 95; $(".control-bar").height(frame_height); $("#main").height(frame_height); var iframe_hei = $(window).height() - 95; document.domain = domain_path; console.log(iframe_hei); $("#main").css("min-height", iframe_hei); $(document).ready(function () { activeMenu(); //导航栏点击 $("#top_menu").on('click', 'span', function () { var data_role = $(this).attr('data-action'); activeMenu(data_role); }); //菜单点击 $(".colot_ttt").on('click', function () { $("#main").attr('src', $(this).attr('href')); }) }); window.onbeforeunload = function () { var main = $("#main"); var data_role = $(main).attr('path_role'); $.cookie('path_role', data_role, {path:"/",domain:domain_path}); $.cookie('path_url', $(main).attr('src'), {path:"/",domain:domain_path}); return null; }; function activeMenu(id) { var path_url; if (id === undefined) { path_url = $.cookie('path_url'); var path_role = $.cookie('path_role'); if(path_role === undefined) { id = 104; }else{ id = path_role; } } var selector = $('[data-role=' + id + ']'); $('[data-control=menu-url]').removeClass('selected_menu'); $(selector).addClass('selected_menu'); //如果url中带了http,需要手动去除 var url = path_url===undefined?$(selector).attr('href'):path_url; path_url = url.replace(/https?:\/\/[^\/]*/, ''); if(path_url === '/zz-jd/outside_hotel_order_list.html') path_url = '/hotel/supplier-backend/index'; //激活导航栏 var main = $(selector).closest('.nav-item').attr('data-role'); var top_menu = $("#top_menu"); var nav = $(top_menu).find("span[data-role=" + main + "]"); $(top_menu).find("span").removeClass('head_selected').addClass('select_hover'); $(nav).removeClass('select_hover').addClass('head_selected'); $(".nav-item").addClass('hidden'); $(".nav-item[data-role='"+ main + "']").removeClass('hidden'); $("#main") .attr('path_role', id) .attr("src", window.location.protocol + '//' + window.location.host + path_url); }