$(document).ready(function () { // 设为首页 $("#setHomePage").click(function () { HomepageFavorite.Homepage(); }); // 加入收藏 $("#addFavorite").click(function () { HomepageFavorite.Favorite('http://www.zlnhzs.com/', '太原中龙霓虹装饰有限公司'); }); // 新页打开 $('a[rel*=external],form[rel*=external]').attr('target', '_blank'); // 弹出图片 $(".imgshow").fancybox({ 'titleShow': true, 'transitionIn': 'elastic', 'transitionOut': 'elastic' }); // 弹出页面 $(".iframe").fancybox({ //'width': '60%', //'height': '70%', 'width': 800, 'height': 650, 'overlayShow': false, 'autoScale': false, 'transitionIn': 'none', 'transitionOut': 'none', 'type': 'iframe', onClosed: function () { if (typeof window.onfancyboxClose == 'function') onfancyboxClose(); } }); // 弹出页面2 $(".iframe2").fancybox({ //'width': '60%', //'height': '70%', 'width': 800, 'height': 700, 'overlayShow': false, 'autoScale': false, 'transitionIn': 'elastic', 'transitionOut': 'elastic', 'type': 'iframe', onClosed: function () { if (typeof window.onfancyboxClose == 'function') onfancyboxClose(); } }); // 弹出页面3 $(".iframe3").fancybox({ //'width': '60%', //'height': '70%', 'width': 400, 'height': 400, 'overlayShow': false, 'autoScale': false, 'transitionIn': 'elastic', 'transitionOut': 'elastic', 'type': 'iframe', onClosed: function () { if (typeof window.onfancyboxClose == 'function') onfancyboxClose(); } }); }) // 页面跳转 var urlto = function (url) { window.location = url; } // 锚点跳转 var goto = function (id) { $("#" + id).ScrollTo(800); } // 弹出页面自定义 function popWin(msg, url, width, height, padding) { if (width == null) width = '70%'; if (height == null) height = '80%'; $.fancybox({ 'padding': padding, 'overlayShow': false, 'autoScale': false, 'transitionIn': 'elastic', 'transitionOut': 'elastic', 'title': msg, 'width': width, 'height': height, 'href': url, 'type': 'iframe' }); return false; } // 弹出页面关闭 function popClose() { $.fancybox.close(); } //设为首页/加入收藏 var HomepageFavorite = { Homepage: function () { if (document.all) { document.body.style.behavior = 'url(#default#homepage)'; document.body.setHomePage(window.location.href); } else if (window.sidebar) { if (window.netscape) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { alert("该操作被浏览器拒绝,如果想启用该功能,请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true"); history.go(-1); } } var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref('browser.startup.homepage', window.location.href); } } , Favorite: function Favorite(sURL, sTitle) { try { window.external.addFavorite(sURL, sTitle); } catch (e) { try { window.sidebar.addPanel(sTitle, sURL, ""); } catch (e) { alert("加入收藏失败,请手动添加."); } } } } // HTML编码 String.prototype.HTMLEncode = function () { var temp = document.createElement("div"); (temp.textContent != null) ? (temp.textContent = this) : (temp.innerText = this); var output = temp.innerHTML; temp = null; return output; } // HTML解码 String.prototype.HTMLDecode = function () { var temp = document.createElement("div"); temp.innerHTML = this; var output = temp.innerText || temp.textContent; temp = null; return output; }