I'm working on an android/ios
app. i need some sort of infinit scroll, so when user scroll and reaching the end of the page new content will load for him.
In the native code i store the new content in an string and then append it to the page with javascript/jquery
.
for android:
String js = "javascript:(function() { document.body.innerHTML += '" + newContent + "';}())";
loadUrl(js);
so far so good, BUT if my newContent
contains a set of specific char this code will fail and nothing append.
I discovered this char so far: '
\n
«
»
If i replace this chars in the newContent
then the code works fine and new content will append to body.
The problem is every time i think it's over and i find all illigal char a new char cause my code to fail.
I also tried to parse my string
to html
then add it, but it fails also.
js = "javascript:(function(){var html = $.parseHTML( '"+newContent+"' ); $(\"body\").append(html);}())";
loadUrl(js);
so is there any general way to get ride of this illegal chars?
any help would be appreciated.