WebBrowser Javascript错误 [英] WebBrowser Javascript error

查看:74
本文介绍了WebBrowser Javascript错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

当我使用webbrowser加载此脚本时,我的脚本出现问题:

Hi!
I have problem with my script when I use webbrowser to load this script:

this.SaveMap = function(){
	
		var NameMap = [];
		NameMap.push(List[0][0]);
		
		for(var i = 0; i < List.length ; i++)
		{
			for(var j = 0; j < NameMap.length; j++)
			{
				if(NameMap[j] != List[i][0])//Here is problem
				{
					NameMap.push(List[i][0]);
					break;
				}
			}
		}
		return NameMap;
	}



我遇到问题:无法为无法识别或空闲的电话检索0的属性

Img(波兰语版本) ) http://forum.miroslawzelent.pl/?qa=blob&qa_blobid=13318802437153965850 [< a href =http://forum.miroslawzelent.pl/?qa=blob&qa_blobid=13318802437153965850target =_ blanktitle =New Window> ^ ]



加载脚本的代码:


I get problem: Unable to retrieve the properties of "0" for unidentified or empty call
Img(Polish version)http://forum.miroslawzelent.pl/?qa=blob&qa_blobid=13318802437153965850[^]

Code which load script:

public void LoadScript(string path)
       {
           HtmlDocument doc = web.Document;
           HtmlElement head = doc.GetElementsByTagName("head")[0];
           HtmlElement s = doc.CreateElement("script");

           HtmlElement headElement = web.Document.GetElementsByTagName("head")[0];
           HtmlElement scriptElement = web.Document.CreateElement("script");
           IHTMLScriptElement element = (IHTMLScriptElement)scriptElement.DomElement;

           JSpath = path;

           try
           {
               using (StreamReader JS = new StreamReader(path))
               {
                   string buff = JS.ReadToEnd();

                   element.text = buff;
                   headElement.AppendChild(scriptElement);
               }
           }

推荐答案

试试这个?



this.SaveMap = function(){



var NameMap = [];

NameMap.push(List [0] [0]);



for(var i = 0; i< List.length; i ++)

{< ($ j $ 0; j< NameMap.length; j ++)

{

if(List [i] .length> 0){

if(NameMap [j]!= List [i] [0])//这里有问题

{

NameMap .push(List [i] [0]);

休息;

}

}

}

}

返回NameMap;

}
try this?

this.SaveMap = function(){

var NameMap = [];
NameMap.push(List[0][0]);

for(var i = 0; i < List.length ; i++)
{
for(var j = 0; j < NameMap.length; j++)
{
if(List[i].length > 0 ){
if(NameMap[j] != List[i][0])//Here is problem
{
NameMap.push(List[i][0]);
break;
}
}
}
}
return NameMap;
}


按照上面的文字 - 我似乎无法忍受保存它以便正确显示。



基本上 - 检查以确保问题行之前List [i]的长度大于0.
as per the text above - i can't seem to save it to show properly.

basically - check to make sure the length of List[i] is greater than 0 before the problem line.


这篇关于WebBrowser Javascript错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆