suresh
suresh

Reputation: 31

iphone uiwebview hyperlink

I have to display UIWebView content using javascript stringbyevaluatingstring.

In my project hyperlink is not working. How to enable the all the links in UIWebView?

Anybody know then please give a piece of sample code or idea.

Upvotes: 0

Views: 661

Answers (2)

Viraj
Viraj

Reputation: 1890

Have you set the property of the UIWebView - Detects Links ?

Upvotes: 0

meronix
meronix

Reputation: 6176

just a sample to try:

in the UIViewController who "own" your UIWebView named: "yourWebView"

// navigate to a new html file:
[yourWebView stringByEvaluatingJavaScriptFromString:@"document.location='aNewHtmlFile.html'"];

// show a normal javascript alert window with a message:
[yourWebView stringByEvaluatingJavaScriptFromString:@"alert('This is what an alert message looks like.');"];

// ask to the html file its own title:
NSString *appS = [yourWebView stringByEvaluatingJavaScriptFromString:@"document.title"];
NSLogg(@"the title is: %@", appS);

// call a personal JS in your html document:
[yourWebView stringByEvaluatingJavaScriptFromString:@"callMyJSFunctionToshowMyAlert('Hallo!');"];
// whit this in your html file:
    <head>
...
    <script>
    function callMyJSFunctionToshowMyAlert(aMsg) {
        alert(aMsg);
    }
    </script>
...
    </head>

if some of these funcs don't works then there may be some error somewhere when you instantiate your UIWebView loading the html file. but what were you looking for?

Upvotes: 2

Related Questions