function addBookMark(url, title){
//将网页添加到收藏addBookMark(window.location,document.title)
if(document.all){
window.external.addFavorite(url,title);
}else if (window.sidebar){
window.sidebar.addPanel(title,url,'');
}else{
alert('添加失败');
}
}
function setHomepage(obj,url) {
// setHome(this, window.location)
try {
obj.style.behavior = 'url(#default#homepage)';
obj.setHomePage(url);
} catch (e) {
if (window.netscape) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (e) {
alert('此操作被浏览器拒绝!\n请在浏览器地址栏输入"about:config"并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为"true",双击即可。');
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage', vrl);
}
}
}
function boxMove(box){
//可移动的层
var w = box.scrollWidth,h = box.scrollHeight;
var iWidth = document.documentElement.clientWidth;
var iHeight = document.documentElement.clientHeight;
var moveX = 0,moveY = 0,moveTop = 0,moveLeft = 0,moveable = false;
box.onmousedown = function(e){
moveable = true;
e = window.event?window.event:e;
moveX = e.clientX-box.offsetLeft;
moveY = e.clientY-box.offsetTop;
box.style.zIndex++;
}
document.onmousemove = function(e){
if(moveable){
e = window.event?window.event:e;
var x = e.clientX - moveX;
var y = e.clientY - moveY;
if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight)){
box.style.left = x + "px";
box.style.top = y + "px";
box.style.margin = "auto";
}
}
}
document.onmouseup = function (){moveable = false;};
}
function getHtmlRoot(){
/*获得html文档的根元素*/
if(document.compatMode.toLowerCase()=="css1compat"){
htmlRoot = document.documentElement;
}else{
htmlRoot = document.body;
}
return htmlRoot;
}
function showWindow(boxId, closeId, showBg){//弹窗
htmlRoot = getHtmlRoot();
box = document.getElementById(boxId);
boxId = '#' + boxId;
closeId = '#' + closeId;
showBox = $(boxId);
showBox.show();
z_index = 20;
moveLeft = (htmlRoot.clientWidth- box.clientWidth)/2 + htmlRoot.scrollLeft +'px';
moveTop = (htmlRoot.clientHeight - box.clientHeight)/2 + htmlRoot.scrollTop;+'px';
showBox.css({position:'absolute', left:moveLeft,zIndex:z_index, top:moveTop});