How to replace Url and href with javascript function
What i want is to remove the event of opening a new page, handle the url with a javascript function so the href is not workin.
Im using titanium appcelerator to make an iPhone app, well its finished but this is an update. Anyway, i have an webView so i can show hyperlinks, but when i click on this link it opens up a page inside that same webView.
Which is where the problem starts, i need to catch the event of opening the url and call a function to open a new webView or safari with the given url.
Im not really that great in html/js/regex, thats why im running into this problem.
Here is an test case: 1. the html is containing an url without href, this must be made clickable so i can open the url. 2. the html is containing an url with href, this must not open the url but use a js function 3. the html is containing url with and without href, both need to be clickable and 开发者_如何学Gocall a js function to open the url in a new webView or safari.
I think that clears up what im expecting to achieve,
here is my code containing the functions i have now for these cases, but the first function works if there is no case 2. And the second function is not calling the event... replacing by just a function also does not work.
Test case
Hope someone can help me out with this
I would try something similar to this, if nothing else it's a great starting point on your issue.
Ok that is just so dumb of me, the html did not have a start nor end. As in the example of brian, in code its saying it needs to include javascript in the html. Which it does not do by default. Added 2 lines to my html and the function works
Now i just need an REGEX which checks if an url has an href, if so add function. If not add href and function.
精彩评论