//忽略页面控件对回车件的响应 function IgnoreEnterKey(p_Event) { var iKeyCode = p_Event.keyCode || p_Event.which; if (iKeyCode == 13) return false; } //兼容不同浏览器的事件触发函数 var DoFireEvent = function (element, event) { if (document.createEventObject) { // IE浏览器支持fireEvent方法 var evt = document.createEventObject(); return element.fireEvent('on' + event, evt); } else { // 其他标准浏览器使用dispatchEvent方法 var evt = document.createEvent('HTMLEvents'); // initEvent接受3个参数: // 事件类型,是否冒泡,是否阻止浏览器的默认行为 evt.initEvent(event, true, true); return !element.dispatchEvent(evt); } }; function GetCategoryTitle(sCategoryName, sUrl, sRel) { var sHtml = ""; sHtml += ''; sHtml += ' '; sHtml += ' '; if (sUrl) { if (!sRel) sRel = ""; sHtml += ' '; } sHtml += ' '; sHtml += '
'; sHtml += ' '; sHtml += ' '; sHtml += ' '; sHtml += ' '; sHtml += '
' + sCategoryName + '
'; sHtml += '
>> 更多..
'; document.write(sHtml); } function GetSubCategoryTitle(sCategoryName, sUrl, sRel) { var sHtml = ""; sHtml += ''; sHtml += ' '; sHtml += ' '; if (sUrl) { if (!sRel) sRel = ""; sHtml += ' '; } sHtml += ' '; sHtml += '
'; sHtml += ' '; sHtml += ' '; sHtml += ' '; sHtml += ' '; sHtml += '
' + sCategoryName + '
'; sHtml += '
>> 更多..
'; document.write(sHtml); } function GetSectionTitle(sCategoryName, sUrl) { document.write(" "); document.write(" "); document.write(" "); document.write(" "); document.write(" "); document.write("
    " + sCategoryName + ""); if (sUrl) { document.write(" >> 更多.."); } document.write("
"); } function GetSectionTitle2(sCategoryName, sUrl) { document.write(" "); document.write(" "); document.write(" "); document.write(" "); document.write(" "); document.write("
 【" + sCategoryName + "】"); if (sUrl) { document.write(" >> 更多.."); } document.write("
"); } //若图片尺寸超出指定范围则自动进行调整 function ResizeImg(imgD, iWidth, iHeight) { if (imgD.style.width != "" || imgD.style.height != "") return; //若已通过css指定了图片大小则不再调整(style="width:) var imgTmp = new Image(); imgTmp.src = imgD.src; if (imgTmp.width != imgD.width || imgTmp.height != imgD.height) return; //若已在页面中指定了图片大小则不再调整( 0 && imgTmp.height > 0) { //未指定高度,只根据宽度按比例缩小 if (iWidth && !iHeight) { if (imgTmp.width > iWidth) { imgD.width = iWidth; imgD.height = (imgTmp.height * iWidth) / imgTmp.width; } return; } //未指定宽度,只根据高度按比例缩小 if (iHeight && !iWidth) { if (imgTmp.height > iHeight) { imgD.height = iHeight; imgD.width = (imgTmp.width * iHeight) / imgTmp.height; } return; } //同时指定了高度和宽度,按原始比例缩小 if (imgTmp.width / imgTmp.height >= iWidth / iHeight) { if (imgTmp.width > iWidth) { imgD.width = iWidth; imgD.height = (imgTmp.height * iWidth) / imgTmp.width; } else { imgD.width = imgTmp.width; imgD.height = imgTmp.height; } } else { if (imgTmp.height > iHeight) { imgD.height = iHeight; imgD.width = (imgTmp.width * iHeight) / imgTmp.height; } else { imgD.width = imgTmp.width; imgD.height = imgTmp.height; } } } } //页面加载时根据设定的尺寸自动对上传图片大小进行调整 function ResizeContentImgs(oParent, iWidth, iHeight) { var _ResizeContentImgs = function() { var oImgs; oImgs = oParent.getElementsByTagName("img"); for(var i = 0; i < oImgs.length; i++) { var oImg = oImgs[i]; ResizeImg(oImg, iWidth, iHeight); if (oImg.parentElement.tagName != "A") { //无链接的图片,点击时打开原图 oImg.style.cursor = "pointer"; oImg.onclick = function(){window.open(this.src);} } } } if (document.all) { window.attachEvent("onload", _ResizeContentImgs); } else { window.addEventListener("load", _ResizeContentImgs, false); } } //获取元素的位置 function getElementPos(elementId) { var ua = navigator.userAgent.toLowerCase(); var isOpera = (ua.indexOf('opera') != -1); var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof var el = document.getElementById(elementId); if(el.parentNode == null || el.style.display == 'none') { return false; } var parent = null; var pos = []; var box; if(el.getBoundingClientRect) //IE { box = el.getBoundingClientRect(); var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop); var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft); return {x:box.left + scrollLeft, y:box.top + scrollTop}; } else if(document.getBoxObjectFor) // gecko { box = document.getBoxObjectFor(el); var borderLeft = (el.style.borderLeftWidth)?parseInt(el.style.borderLeftWidth):0; var borderTop = (el.style.borderTopWidth)?parseInt(el.style.borderTopWidth):0; pos = [box.x - borderLeft, box.y - borderTop]; } else // safari & opera { pos = [el.offsetLeft, el.offsetTop]; parent = el.offsetParent; if (parent != el) { while (parent) { pos[0] += parent.offsetLeft; pos[1] += parent.offsetTop; parent = parent.offsetParent; } } if (ua.indexOf('opera') != -1 || ( ua.indexOf('safari') != -1 && el.style.position == 'absolute' )) { pos[0] -= document.body.offsetLeft; pos[1] -= document.body.offsetTop; } } if (el.parentNode) { parent = el.parentNode; } else { parent = null; } while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') { // account for any scrolled ancestors pos[0] -= parent.scrollLeft; pos[1] -= parent.scrollTop; if (parent.parentNode) { parent = parent.parentNode; } else { parent = null; } } return {x:pos[0], y:pos[1]}; }