吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 392|回复: 10
收起左侧

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

[复制链接]
冥界3大法王 发表于 2024-11-18 09:21
image.png


[JavaScript] 纯文本查看 复制代码
/* --------------- 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.     [url]https://www.helpandmanual.com[/url]

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()[0].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[i], value, (value && hmAnimate)); 
	}
  }
  HMTogglesAllExpanded = value;
}

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

var HMToggle = function() { 
	var op = HMToggle.arguments[0];
	for (i=1; i<HMToggle.arguments.length; i++) {
	  var objID = HMToggle.arguments[i]; 
       	  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[0] = startL;
    sizeStart[1] = startT;
    if (parentScope) {
      sizeStart[0] = sizeStart[0] + parent.$('#hmcontent').offset().left - $(document).scrollLeft();
      sizeStart[1] = sizeStart[1] + parent.$('#hmcontent').offset().top - $(document).scrollTop();
    }
    lightbox.css({'left': sizeStart[0]+'px', 'top': sizeStart[1]+'px'});
    lightbox.show();
    lightbox.animate({ left: sizeEnd[0]-lightboxObject.position().left, top: sizeEnd[1]-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[0]-lightboxObject.position().left, top: size[1]-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[0]-lightboxObject.position().left, top: sizeStart[1]-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[cCheck].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[0]);
	var isPicture = false;
	for (i=1; i<HMInitToggle.arguments.length-1; i=i+2) { 
		if (HMInitToggle.arguments[i] == "onclick") {
		  node.onclick = Function(HMInitToggle.arguments[i+1]); 
		}
		if (HMInitToggle.arguments[i].substring(0,6) == "hm.src") {
		  node.setAttribute(HMInitToggle.arguments[i], decodeURI(HMInitToggle.arguments[i+1]));
	      var img = new Image();
		  img.src = HMInitToggle.arguments[i+1];
		}
		else { 
		  node.setAttribute(HMInitToggle.arguments[i], HMInitToggle.arguments[i+1]);
		  if ((HMInitToggle.arguments[i] == "hm.type") && (HMInitToggle.arguments[i+1] == "picture")) { isPicture = true; } 
		}
	}
	if (isPicture) {
	   var aLink = node.parentNode;
	   if (aLink.nodeName.toLowerCase() == "a") {
	   	 if (hmImageLightbox) {
	  	   HMGallery[HMGallery.length] = node;
           aLink.href = "javascript:HMShowPictureLightbox('" + HMInitToggle.arguments[0] +"')";
	   	 }
	   	 else {
	  	   HMToggles[HMToggles.length] = node;
           aLink.href = "javascript:HMToggle('toggle','" + HMInitToggle.arguments[0] +"')";
	  	 }
	   }
	}
	else {
	  var mustExpand = HMSearchCheck(node); 
	  HMToggles[HMToggles.length] = 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[0]);
debug这一行的代码,应该是HMInitToggle.arguments[0]这一行没有获取到对应的值,导致byId找不到元素

免费评分

参与人数 1吾爱币 +1 收起 理由
冥界3大法王 + 1 热心回复!

查看全部评分

shyjeai 发表于 2024-11-18 09:47
var node = document.getElementById(HMInitToggle.arguments[0]);  问题就在这里,HMInitToggle.arguments[0])这里如果是空的你就获取不到元素
if(HMInitToggle.arguments[0])){
var node = document.getElementById(HMInitToggle.arguments[0]);
用到node操作放到这里
}

免费评分

参与人数 1吾爱币 +1 收起 理由
冥界3大法王 + 1 谢谢@Thanks!

查看全部评分

 楼主| 冥界3大法王 发表于 2024-11-18 09:50
感谢两位指教,发现是某款软件的皮肤(把它改扩展名为RAR,竟然需要密码,没有密码也就得不到上面的JS文件了)
于是我灵机一动,网上下载一个老版本的皮肤,挪来用,再生成就不会出现错误了。
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
这应该是浏览器版本故障?
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-12-4 00:40

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表