I am trying to add Readability (a third party app) compatibility with my web browser, and I tracked down a bookmarklet to save a page to Readability:
javascript:(%28function%28%29%7Bwindow.baseUrl%3D%27http%3A//www.readability.com%27%3Bwindow.readabilityToken%3D%27bbRmvVb9nTNRWSVEGb9yrcFP4USUHnTjk2EVWXjn%27%3Bvar%20s%3Ddocument.createElement%28%27script%27%29%3Bs.setAttribute%28%27type%27%2C%27text/javascript%27%29%3Bs.setAttribute%28%27charset%27%2C%27UTF-8%27%29%3Bs.setAttribute%28%27src%27%2CbaseUrl%2B%27/bookmarklet/read.js%27%29%3Bdocument.documentElement.appendChild%28s%29%3B%7D%29%28%29)
however, I can’t seem to get it to work. It works in desktop Safari and mobile/iPhone Safari. But both of the methods below do nothing:
[webview stringByEvaluatingJavaScriptFromString: readability];
[webview loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: readability]]];
(readability is a string with the value above)
Is there another method to run javascript bookmarklets that I am unaware of or am I doing something wrong? Help is much appreciated.
Greg
You got this error is because the javascript url is encoded, you should decode the javascript string, (may be you use NSURL to pass the string, so it was encoded by NSURL)
then use the webview stringByEvaluatingJavaScriptFromString, this solution work well