Javascript Returning a Type Error "Unable to get property '1' of undefined or null reference" -
i can't life of me find out error means in relation code.
html
<title>untitled document</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="../../styles.css" type="text/css"> <body bgcolor="#ffffff" text="#000000" link="#0033cc" vlink="#0033cc" alink="#0033cc"> <p><font face="arial, helvetica, sans-serif"><b><font color="#000000">job ref:</font></b><font color="#000000">12345 <br> <b>position:</b> position title <br> <b>organisation:</b> organisation name <br> <b>location: </b> uk, england, london <br> <b>closing date:</b> 24/09/2015<br> <b>job type:</b> permanent <br> <b>salary:</b> £100,000 per annum </font></font></p> <p> </p> <p><font color="#000000" face="arial, helvetica, sans-serif"><b>details:</b></font></p> <p><font color="#000000" face="arial, helvetica, sans-serif">this description</font></p> </body> </html>
javascript
dataextractor.addheader(1, 'country'); var tmp = document.body.outerhtml.match(/location: <\/b> ([^,]+), ([^,]+), ([^,]+)/i); var country = tmp[1] if (country) { (var = 0; < country.length; i++) { dataextractor.startnewresult(); dataextractor.addresult(1, country[i]); } }
when run gives me error in title. can shed light on i'm missing?
thank you
have checked if tmp array? try following piece:
var country if( tmp ){ country = tmp[1] }else{ alert('tmp not set') }
Comments
Post a Comment