3

Suppose I have one Webview over another and i am loading a page inside the inner web view. Now I want to disable all the user interactions of the outer Webview. How can I achieve this in desktop programming?

Here goes the code segment:

IBOutlet WebView *innerWebView;
IBOutlet WebView *outerWebView;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
   // NSString *path = [[NSBundle mainBundle] pathForResource:@"main" ofType:@"html"];
   // NSURL *url = [NSURL fileURLWithPath:path];
    [[myWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://icicibank.com"]]];
    [outerWebView setDrawsBackground:NO];
    [outerWebView setEditable:NO];

}
- (void)webView:(WebView *)webView decidePolicyForNewWindowAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request newFrameName:(NSString *)frameName decisionListener:(id < WebPolicyDecisionListener >)listener{
    [myWebView setDrawsBackground:NO];
    [myWebView setEditable:NO];
    [outerWebView setDrawsBackground:YES];
    [outerWebView setEditable:YES];
    NSLog(@"hello");
    [[outerWebView mainFrame] loadRequest:request];
    [outerWebView webViewShow:outerWebView];
}

These are the outlets.

Vervious
  • 5,559
  • 3
  • 38
  • 57
user1295948
  • 303
  • 1
  • 5
  • 15

2 Answers2

1

Check the accepted answer for this question:

Cocoa webView - Disable all interaction

The answer talks about a couple of user events. You could select the methods from WebUIDelegate protocol and WebEditingDelegate protocol which would suit your need.

Community
  • 1
  • 1
Rakesh
  • 3,370
  • 2
  • 23
  • 41
0

Put all your html code from BODY between <div onmousedown="return false"> ... </div> . This will help you avoid users from dragging images for instance ...

Add this method too:

//Disabling the right click menu 
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems {
    return nil;
}
Artur
  • 61
  • 5