Don't pass a string literal as the argument for search(). Any non-regular expression passed to search() will be used to create a regular expression and any "special" characters in it will lose their literal meaning. For example:
"Hello. Goodbye".search(".")
Will return 0
, not 5
where the .
character is. This is because .
has a special meaning in a regular expression and will match any character except for a newline.
You actually require the indexOf() method, which does exactly the same thing but takes a string as its argument, and returns the position of the substring match within the string:
var str = "hello<br/>goodbye";
if(str.indexOf("<br/>") == -1) { // String not found
//execute certain code
}
More information at the MDC documentation for search.