[Javascript] Comparing Strings

Timothy White weirdit at gmail.com
Thu Aug 25 02:55:49 CDT 2005


I'm using some AJAX in an application I'm building. At the moment
until I do some more advanced work I just want to compare the AJAX
results I get with the contents of a div. And if they are different
the change the div contents so they are effectively the same.
The problem is that even when the results are the same, it still
thinks they are different.
So the following is always false when it should be true practically all the time

if (message_text == messages.innerHTML){

I know I must be missing something, they both are strings (according
to typeof) and I know the contents are the same cause the AJAX is
returning the same thing every time.
I've even put a test condition right after "message_text =
messages.innerHTML;" and it still says that they are not equal.

I must be missing something

This should be simple!!

Thanks

Tim
p.s. It needs to be cross browser as well, so I don't want a
Firefox/Mozilla or IE only solution



More information about the Javascript mailing list