Auto-search webpage for text, w/ refresh
|
|
@JoeSimmons
I've taken Chris D's method and put it into a function if anyone needs a simple, quick way to search the html of the body... Yeah my method actually and it doesn't search the html at all, just the text content. "Every day above ground is a good day." |
|
|
with "can't", you must have to do: "//child::text()[contains(\"can't\")]" |
|
|
Would it be faster to do a evaluate call, rather than a call on the innerHTML after the page has initialized? |
|
|
@avg Yes I know about it, I was just telling JoeSimmon that he has to escape the "text" parameter of his function before adding it to the xpath. Try to escape for an xpath the following text: |
|
|
You can do that as well: "Can't \"escape\" this!" |
|
|
I know how to escape string, I'm saying that is not possible to escape it inside an xpath, try it if you think that you can do it.
|
|
|
I'm reading these posts between Aquilax and avg, and I don't understand where the communication is breaking down. avg, look at Joe's function here and then read Aquilax's reply here. |
|
|
"//child::text()[contains(\"hello there! i am \\\"escaped\\\"\")]" wouldn't that do it for @znerp: Doesn't really matter where it started; this is an interesting issue regardless. |
|
|
// Search body's inner html
function searchDoc(t) {
return document.evaluate("//child::text()[contains(.,'"+t+"')]",document,null,9,null).singleNodeValue!=null;
}
alert(searchDoc("wouldn't"));
Doesn't work no matter what you try. I tried adding slashes, using addslahes(t) and all.
"None are more hopelessly enslaved than those who falsely believe they are free." - Johann Wolfgang von Goethe |
|
|
Doesn't really matter where it started; this is an interesting issue regardless. It's relatively interesting, yes, but you seemed to be trying to give a lesson on escaping characters but I think everyone here knows how to escape quotes. |
|
|
I've google it a little bit and seems to be a problem of xpath 1.0, which doesn't define any escape method. Most of the people suggested to use the concat function. I didn't test it but you should be able to do something like this one:
|
|
|
It's relatively interesting, yes, but you seemed to be trying to give a lesson on escaping characters but I think everyone here knows how to escape quotes. I appreciate that everyone knows how to escape. Clearly however, there is an issue... otherwise this discussion would be nonexistent. Did anyone try my string suggestion? I'm not sure if it'll work, and I haven't tried it. It was: FOR TESTING: hello there! i am "escaped" "//child::text()[contains(\"hello there! i am \\\"escaped\\\"\")]" EDIT: Appears that this does not work.... |
