I'm trying to run the body of a website through a javascript search I created. It works fine, except there are no spaces in between words; as well as the fact html in this xcase the image does not appear/show. Any solutions?
Therefore i need help getting the image to show. Then getting the text as seen to show on the browser with spaces.
This can all be found in the srctxt variable. Which is where i think the problem is.
Please, note i have only fairly basic knowledge of Javascript.
<body>
<script type = "text/javascript">
var keyword;
var srctxt;
var srctxtarray;
keyword = "archery";
srctxt = "hellow blah blah blah archery <img src =\"megan_fox.jpg\">hello test archery";
srctxtarray= srctxt.split(" ");
for (var i=0;i<srctxtarray.length;i++){
if(srctxtarray[i] != keyword){
document.write(srctxtarray[i]);
}
else{
document.write("<b class=\"red\">");
document.write(srctxtarray[i] );
document.write("</b>");
}
}
</script>
</body>