冥界3大法王 发表于 2024-11-18 09:21

求教,这个JS错误能改吗?




/* --------------- Script (c) 2024 EC Software ---------------
This script was created by Help+Manual. It is designed for use
in combination with the output of Help+Manual and must not
be used outside this context.   https://www.helpandmanual.com

Do not modify this file! It will be overwritten by Help+Manual.
-----------------------------------------------------------------*/

var topicInitScriptAvailable = true;
var HMToggles = new Array();
var HMGallery = new Array();
var HMTogglesAllExpanded = false;

function hmmin(v1, v2) { if (v1<v2) return v1; return v2 }
function hmmax(v1, v2) { if (v1>v2) return v1; return v2 }

var hasParent = (parent.hmNavigationFrame && /^https??:\/\//im.test(document.location));
if (hasParent) {
        var thisHref = document.location.href.substr(document.location.href.lastIndexOf("/") + 1),
                thisTitle = $("title").first().innerHTML;
        if (thisHref.indexOf("?") > 0)
                thisHref = thisHref.substr(0,thisHref.lastIndexOf("?"));
       
        // Push topic state to main page
        parent.pushTopicState(thisTitle,thisHref);
}

var HMSyncTOC = function(indexPageUrl, selfUrl) {
   if (location.search.lastIndexOf("toc=0")<=0) {
   if (parent.hmNavigationFrame) { parent.lazysync(selfUrl); }
   else if ((hmForceRedirect) && (parent.location) && (parent.location.href)) { parent.location.href = indexPageUrl+'?'+selfUrl; }
   }
}
       
var HMToggleExpandAll = function(value) {
if (HMToggles.length != null){
    for (i=0; i<HMToggles.length; i++){
      HMToggleExpand(HMToggles, value, (value && hmAnimate));
        }
}
HMTogglesAllExpanded = value;
}

var HMAnyToggleOpen = function() {
var anyOpen = false;
if (HMToggles.length != null){
    for (i=0; i<HMToggles.length; i++){
          if (HMToggles.getAttribute("hm.state")=='1') anyOpen = true;
        }
}
if (!anyOpen) HMTogglesAllExpanded = false;
return anyOpen;
}

var HMToggle = function() {
        var op = HMToggle.arguments;
        for (i=1; i<HMToggle.arguments.length; i++) {
          var objID = HMToggle.arguments;
                 var obj = document.getElementById(objID);
          switch (op) {
                case "toggle":
                  var state = obj.getAttribute("hm.state");
                  if (state == null) { state = "0" };
                  HMToggleExpand(obj, (state != "1"), hmAnimate);
                  break;

                case "expand":
                  HMToggleExpand(obj, true, false);
                  break;

                case "collapse":
                  HMToggleExpand(obj, false, false);
                  break;
          }
        }
}

var HMToggleExpand = function(obj, value, animate) {
        tagName = obj.nodeName.toLowerCase();
        switch (tagName) {
                case "span":
                  HMToggleExpandText(obj, value, animate);
                  break;
                case "div":
                  HMToggleExpandDropdown(obj, value, animate);
                  break;
                case "img":
                  HMToggleExpandPicture(obj, value, animate);
                  break;
        }
        obj.setAttribute("hm.state", value ? "1" : "0");
}

var HMToggleExpandText = function(obj, value, animate) {
obj.style.display = (value ? "inline" : "none");//cannot be animated
}

var HMToggleExpandDropdown = function(obj, value, animate) {
if (animate) {
        /* $(obj).stop(); don't stop here */
    if (value) {
      $(obj).slideDown('fast');
    }
    else {
          $(obj).animate({ height: 'toggle' }, 'fast', function() {
                if (document.all && !window.opera) { // Avoid collapsing margins bug in IE
                    var dummy = $(obj).prev();
                    if ($(dummy).outerHeight!=0) dummy = $('<div style="height:1px"></div>').insertBefore(obj);
                    else $(dummy).css('display', 'block');
          $(dummy).css('display', 'none');
      }
          });
    }
}
else {
    obj.style.display = (value ? "block" : "none");
}
}

var HMToggleExpandPicture = function(obj, value, animate) {
var oldFile = (value ? obj.getAttribute("hm.src0") : obj.getAttribute("hm.src1"));
var newFile = (value ? obj.getAttribute("hm.src1") : obj.getAttribute("hm.src0"));
var newSrc = obj.src.replace(oldFile, newFile);
var isToggleIcon = (obj.getAttribute("hm.type")=="dropdown");

if ((!isToggleIcon) && (animate)) {
        $(obj).stop();
       
        var newImg = new Image();
    newImg.onload = function() {
          var newWidth= newImg.width;
          var newHeight = newImg.height;
          var oldWidth= obj.width;
          var oldHeight = obj.height;

      if ((newWidth > 0) && (newHeight > 0)) {
      if ((newWidth == oldWidth) && (newHeight == oldHeight)) {
          obj.src = newSrc;
      }
      else {
          $(obj).animate({ width: newWidth, height: newHeight }, 'fast', function() {
                obj.src = newSrc;
          });
          }
          }
    };
        newImg.src = newSrc;
}
else {
    obj.src = newSrc;
}
var newTitle = (value ? obj.getAttribute("hm.title1") : obj.getAttribute("hm.title0"));
if (newTitle != null) { obj.title = newTitle; }
var newCaption = (value ? obj.getAttribute("hm.caption1") : obj.getAttribute("hm.caption0"));
if (newCaption != null) { obj.parentNode.parentNode.parentNode.nextSibling.firstChild.firstChild.innerHTML = newCaption; }
}

var HMShowPictureLightbox = function(objID) {
var obj = document.getElementById(objID); /* our <img> clicked */

var startL = $(obj).offset().left;
var startT = $(obj).offset().top;
var startW = $(obj).outerWidth();
var startH = $(obj).outerHeight();

var oldFile = obj.getAttribute("hm.src0");
var newFile = obj.getAttribute("hm.src1");
var newSrc = obj.src.replace(oldFile, newFile);
var newTitle = obj.getAttribute("hm.title1");
var newCaption = obj.getAttribute("hm.caption1");

var htmlCode = '<img id="hmlightboximage" src="' + newSrc + '" alt="' + newTitle + '"/>';
var imgPreloader = new Image();
imgPreloader.onload = function() {
        HMShowLightbox(htmlCode, startL, startT, startW, startH, imgPreloader.width, imgPreloader.height, newCaption, true, false);
};
imgPreloader.src = newSrc;

}

var HMShowVideoLightbox = function(event, obj, htmlcode, vWidth, vHeight) {
var startL = $(obj).offset().left;
var startT = $(obj).offset().top;
var startW = $(obj).outerWidth();
var startH = $(obj).outerHeight();

if (event.stopPropagation) { event.stopPropagation(); } else { event.cancelBubble = true; } //MSIE

HMShowLightbox(htmlcode, startL, startT, startW, startH, vWidth, vHeight, '', false, true);
}

var HMShowLightbox = function(htmlCode, startL, startT, startW, startH, endW, endH, newCaption, doAnimate, isVideo) {
/* Find our scope:
   * 1) Is this an orphan window or part of a webhelp frame?
   * 2) If it is a webhelp frame, is it an iframe or classic <frame>?
   * 3) Can we do cross-frame scripting? (not possible in Chrome locally)
   */
var parentScope = ((parent.hmNavigationFrame) && (parent.document.getElementById('hmnavigation')) && (parent.document.getElementById('hmnavigation').nodeName.toLowerCase()=='iframe'));
var lightboxWindow = $(window);
var lightboxDocument = $(document);
var lightboxBody = $('body');
var lighboxScrollLayer = null;
if (parentScope) {          /* use entire window for lightbox */
        lightboxBody = parent.$('body');
           lightboxDocument = parent.$(document);
    lightboxWindow = parent.window;
}

$(lightboxBody).prepend('<div id="hmlightboxbackground" style="z-index:99997;border:none;padding:0;margin:0;position:absolute;left:0;top:0;background-color:#7F7F7F"></div>');
var lightboxBackground = parentScope ? parent.$('#hmlightboxbackground') : $('#hmlightboxbackground');
lightboxBackground.css('opacity', '0.5');

if (parentScope) {
        $(lightboxBody).prepend('<div id="hmlightboxscrolllayer" style="z-index:99998;border:none;padding:0;margin:0;position:absolute;left:0;top:0;background:none;overflow:auto"></div>');
        lighboxScrollLayer = parent.$('#hmlightboxscrolllayer');
        lightboxBody = lighboxScrollLayer;
}

$(lightboxBody).prepend('<div id="hmlightbox" style="z-index:99999;position:absolute;display:none"></div>');
var lightbox = parentScope ? parent.$('#hmlightbox') : $('#hmlightbox');
var lightboxObject = $(htmlCode).appendTo(lightbox);
var lightboxCaption = null;
if (newCaption != null) {
        $(lightbox).append('<p id="hmlightboxcaption">' +newCaption+ '</p>');
        lightboxCaption = parentScope ? parent.$('#hmlightboxcaption') : $('#hmlightboxcaption');
}       

if (endW == 0) {
        if ((startW/startH) > ($(lightboxWindow).width()/$(lightboxWindow).height())) {
                endW = $(lightboxWindow).width();
                endH = endW / startW * startH;
        }
        else {
                endH = $(lightboxWindow).height();
                endW = endH / startH * startW;
        }
}

var lightboxSpeed = 300;
var sizeStart; /* keep initial size for hide animation */
var maxW = endW;
var maxH = endH;
if (hmLightboxConstrained) {
    if (endW > ($(lightboxWindow).width()-40)) {
          endW = $(lightboxWindow).width()-40;
          if (endW > maxW) endW = maxW;
          endH = maxH * endW / maxW;
    }
        if (endH > $(lightboxWindow).height()-40) {
          endH = $(lightboxWindow).height()-40;
          if (endH > maxH) endH = maxH;
          endH = maxW * endH / maxH;
        }
}

lightboxObject.css({'width': endW+'px', 'height': endH+'px'});
if (lightboxCaption!=null) lightboxCaption.css('width', endW+'px');
if (hmAnimate&&doAnimate) {
        if (lightboxCaption!=null) lightboxCaption.css('display', 'none'); /* hide caption during animation */
        var sizeStart = lightboxGetsize();
        lightboxResize();
        var sizeEnd = lightboxGetsize();
    lightboxObject.css({'width': startW + 'px', 'height': startH + 'px'});
          
    sizeStart = startL;
    sizeStart = startT;
    if (parentScope) {
      sizeStart = sizeStart + parent.$('#hmcontent').offset().left - $(document).scrollLeft();
      sizeStart = sizeStart + parent.$('#hmcontent').offset().top - $(document).scrollTop();
    }
    lightbox.css({'left': sizeStart+'px', 'top': sizeStart+'px'});
    lightbox.show();
    lightbox.animate({ left: sizeEnd-lightboxObject.position().left, top: sizeEnd-lightboxObject.position().top },
                     lightboxSpeed,
                     function() {
                         if (lightboxCaption!=null) lightboxCaption.css('display', 'block');
                     }
                     );
                        
    lightboxObject.animate({ width: endW, height: endH }, lightboxSpeed);
}
else {
        lightbox.show();       
    lightboxResize();
}

$(lightboxWindow).bind('resize.hmlightbox', lightboxResize);
$(lightboxWindow).bind('scroll.hmlightbox', lightboxScroll);
$(lightboxBody).bind('click.hmlightbox', lightboxClick);
$(window).bind('keydown.hmlightbox', lightboxKeydown);
$(lightbox).focus();

function lightboxScroll() {
    lightboxBackground.css('width', (($(lightboxDocument).scrollLeft() > 0) ? $(lightboxDocument).width() : $(lightboxWindow).width()) +'px');
    lightboxBackground.css('height', (($(lightboxDocument).scrollTop() > 0) ? $(lightboxDocument).height() : $(lightboxWindow).height()) +'px');
}
       
function lightboxResize() {
    if (hmLightboxConstrained) {
          var tmpW = endW,
                  tmpH = endH;
          endW = $(lightboxWindow).width()-40;
          endH = $(lightboxWindow).height()-40;
          if (endW > maxW) endW = maxW;
          if (endH > maxH) endH = maxH;

      if ((tmpW != endW) || (tmpH != endH)) {
      endH = maxH * endW / maxW;
                if (endH > $(lightboxWindow).height()-40) {
                        endH = $(lightboxWindow).height()-40;
                        if (endH > maxH) endH = maxH;
                        endW = maxW * endH / maxH;
                }
      lightboxObject.css({'width': endW+'px', 'height': endH+'px'});
          if (lightboxCaption!=null) lightboxCaption.css('width', endW+'px');
          }
        }

        var size = lightboxGetsize();
    lightbox.css({ left: size-lightboxObject.position().left, top: size-lightboxObject.position().top });
   
    if (lighboxScrollLayer!=null) {
      lighboxScrollLayer.css({'width': $(lightboxWindow).width()+'px', 'height': $(lightboxWindow).height()+'px'});
    }
    lightboxScroll();
}

function lightboxGetsize() {
        var lbW= lightbox.width();
        var lbH= lightbox.height();

        if (isVideo) {
          lbW = endW;
          lbH = endH;
    }
        var newW = hmmax(lbW + 40, lightboxDocument.width());
        var newH = hmmax(lbH + 40, lightboxDocument.height());
        var newL = hmmax(20, parseInt(($(lightboxWindow).width() - lbW)/2) + (parentScope ? 0 : lightboxDocument.scrollLeft()));
        var newT = hmmax(20, parseInt(($(lightboxWindow).height() - lbH)/2) + (parentScope ? 0 : lightboxDocument.scrollTop()));
        var size = new Array(newL, newT, newW, newH);
        return size;
}

function lightboxKeydown(e) {
        if (e.keyCode == 27) lightboxClose();
}

function lightboxClick(e) {
    var        canClose = (!isVideo) ||
                   (e.pageX < lightbox.position().left) || (e.pageY < lightbox.position().top) ||
                   (e.pageX > lightbox.position().left+lightbox.width()) || (e.pageY > lightbox.position().top+lightbox.height());       
    if (canClose) lightboxClose();
}

function lightboxClose() {
        if (hmAnimate&&doAnimate) {
      if (lightboxCaption!=null) lightboxCaption.css('display', 'none'); /* hide caption during animation */
      lightboxObject.animate({ width: startW, height: startH }, lightboxSpeed);
      lightbox.animate({ left: sizeStart-lightboxObject.position().left, top: sizeStart-lightboxObject.position().top },
                             lightboxSpeed,
                             function() {
                                    lightbox.remove();
                                    if (lighboxScrollLayer!=null) lighboxScrollLayer.remove();
                             lightboxBackground.remove();
                     }
                      );
        }
        else {
      lightbox.remove();
      if (lighboxScrollLayer!=null) lighboxScrollLayer.remove();
          lightboxBackground.remove();
        }
    $(lightboxWindow).unbind('.hmlightbox');
    $(lightboxBody).unbind('.hmlightbox');
    $(window).unbind('.hmlightbox');
}

}



var HMSearchCheck = function(obj) {
var foundHilite = window.location.search.lastIndexOf("zoom_highlight") > 0;
if (!foundHilite) {
    var fontTags = obj.getElementsByTagName("FONT");
if (fontTags.length == 0)
fontTags = obj.getElementsByTagName("font");
    if (fontTags.length > 0) {
      var hStyle = "";
      for (var cCheck = 0; cCheck < fontTags.length; cCheck++) {
      hStyle = fontTags.style.cssText;
      if (hStyle.indexOf("BACKGROUND-COLOR") == 0 || hStyle.indexOf("background-color") == 0) {
          foundHilite = true;
          break;
      }
      }
    }
}
return foundHilite;   
}

var HMInitToggle = function() {
if (document.getElementById) {
        var node = document.getElementById(HMInitToggle.arguments);
        var isPicture = false;
        for (i=1; i<HMInitToggle.arguments.length-1; i=i+2) {
                if (HMInitToggle.arguments == "onclick") {
                  node.onclick = Function(HMInitToggle.arguments);
                }
                if (HMInitToggle.arguments.substring(0,6) == "hm.src") {
                  node.setAttribute(HMInitToggle.arguments, decodeURI(HMInitToggle.arguments));
              var img = new Image();
                  img.src = HMInitToggle.arguments;
                }
                else {
                  node.setAttribute(HMInitToggle.arguments, HMInitToggle.arguments);
                  if ((HMInitToggle.arguments == "hm.type") && (HMInitToggle.arguments == "picture")) { isPicture = true; }
                }
        }
        if (isPicture) {
           var aLink = node.parentNode;
           if (aLink.nodeName.toLowerCase() == "a") {
                  if (hmImageLightbox) {
                     HMGallery = node;
         aLink.href = "javascript:HMShowPictureLightbox('" + HMInitToggle.arguments +"')";
                  }
                  else {
                     HMToggles = node;
         aLink.href = "javascript:HMToggle('toggle','" + HMInitToggle.arguments +"')";
                 }
           }
        }
        else {
          var mustExpand = HMSearchCheck(node);
          HMToggles = node;
      if (mustExpand) {
      node.setAttribute("hm.state", "1");
      var nodeImg = document.getElementById(node.getAttribute("id")+'_ICON');
      if (nodeImg) { HMToggleExpand(nodeImg, true); }
      }
          HMToggleExpand(node, ((node.getAttribute("hm.state") == "1") || mustExpand));
    }
}
}

var HMTrackTopiclink = function(obj) {
    if (parent.frames.length>0) {
      if (parent.gaaccount) { parent.track("exit", obj.href); }
    }
}

var hmshowPopup = function(event, txt, trigger) {

        $('#hmpopupdiv').stop().remove();
               
        var pop = $('<div id="hmpopupdiv"></div>').appendTo('body');
        if (hmPopupSticky) {
      $('body').bind(hmBrowser.touchend + '.hmpopup', hmhidePopup);
      $('body').bind('keydown.hmpopup', function(e) { if (e.keyCode == 27) hmhidePopup(); } );
    }             
        pop.html(txt);
    var posLeft = event.clientX+$(document).scrollLeft();
    var posTop =event.clientY+$(document).scrollTop();

        var maxW = $(window).width()/1.5;
        var w = pop.width();
        if (w > maxW) pop.width(maxW);
        var t = 20 + posTop;         
        var l = (posLeft - w/2);
        if (l < 10) l = 10;
        if ((l + pop.outerWidth()) > $(window).width()) l = $(window).width() - pop.outerWidth();
        if (l < 0) l = 0;
        pop.css( { left: l+'px', top: t+'px'} );
        if (hmAnimate) pop.show('fast');
        else pop.show();
}

var hmhidePopup = function() {
    if (hmPopupSticky) $("body").unbind(".hmpopup");
    var pop = $('#hmpopupdiv');
    if (pop.length>0) {//hide, don't remove
      if (hmAnimate) pop.hide('fast');
      else $(hmpopupdiv).hide();
    }
}

dzzZOne 发表于 2024-11-18 09:27

debug看看416行的node为什么会是null呗

nevermyloves 发表于 2024-11-18 09:41

var node = document.getElementById(HMInitToggle.arguments);
debug这一行的代码,应该是HMInitToggle.arguments这一行没有获取到对应的值,导致byId找不到元素

shyjeai 发表于 2024-11-18 09:47

var node = document.getElementById(HMInitToggle.arguments);问题就在这里,HMInitToggle.arguments)这里如果是空的你就获取不到元素
if(HMInitToggle.arguments)){
var node = document.getElementById(HMInitToggle.arguments);
用到node操作放到这里
}

冥界3大法王 发表于 2024-11-18 09:50

感谢两位指教,发现是某款软件的皮肤(把它改扩展名为RAR,竟然需要密码,没有密码也就得不到上面的JS文件了)
于是我灵机一动,网上下载一个老版本的皮肤,挪来用,再生成就不会出现错误了。{:301_988:}

bfbkj998 发表于 2024-11-18 10:04

吾爱的大神真多,总有人帮答疑!

wangjichuan 发表于 2024-11-18 10:06

吾爱的大神真多,总有人帮答疑!

冥界3大法王 发表于 2024-11-18 10:26

不过发现有个新的严重问题,中文乱码了。

hwn0412 发表于 2024-11-18 10:35

冥界3大法王 发表于 2024-11-18 10:26
不过发现有个新的严重问题,中文乱码了。

中文乱码跟你文件保存的编码格式有关系。

lovemoney 发表于 2024-11-18 12:38

这应该是浏览器版本故障?
页: [1] 2
查看完整版本: 求教,这个JS错误能改吗?