Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi!
I have problem with my script when I use webbrowser to load this script:
JavaScript
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;
	}

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:
C#
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);
               }
           }
Posted

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;
}
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900