Handling Javascript window requests in WebKit

Discussion in 'Mac Programming' started by drummingsoccer, Jan 9, 2013.

  1. drummingsoccer, Jan 9, 2013
    Last edited: Jan 16, 2013

    drummingsoccer macrumors newbie

    Jan 9, 2013
    Hello all, I've been a lurker here for a while but decided to finally make an account.

    I have been designing websites with html and a bit of javascript and php for a few years now, and I have just recently decided to branch into programming actual applications. I learned the basics of C from various online resources and made a few projects, and have since moved onto Objective C.

    Some people may find it easier to read about EVERYTHING at once and try to retain all that, but my approach for everything from html to obj-C has been to make many small projects to learn things in a hands-on way and learn to solve my problems and learn new things as I came across them.

    Right now, I'm working on a simple browser with the WebKit framework. It's a document-based application in Xcode that works fine except for one thing. For some reason, I can't get javascript window requests to open properly. I've read the documentation on doing this and have implemented it exactly as specified in the documentation (bottom of the page). I handled the UIDelegate part by simply adding
    [webView setUIDelegate:self] ;
    to the top of the file. All the other things that I took from the documentation such as displaying the current page's title and url have worked fine, but this doesn't. When I click on something to open in a new window, a new window IS opened. However, it's a duplicate of the original browser window with nothing loaded in the WebView. I have search all over the internet and examined my code until my eyes hurt, and I can't figure out why it's not working! Is there some little snippet that's left out in the documentation?

    I can provide the code if anyone finds it necessary, but you can simulate the problem simply by creating a document-based Cocoa application in Xcode, making a page (preferably one with a link to open a new window) open in a WebView, and adding the code for javascript window requests that is provided in the documentation that I linked above.

    I assumed at first that this was being caused by me implementing a auto-loading homepage, but the problem persists even when I remove any code that could possibly be conflicting!

    What am I doing wrong?
  2. drummingsoccer thread starter macrumors newbie

    Jan 9, 2013
    Okay, if no one has any info for me, is there perhaps a place where I could go that would be able to better answer my question? Some other forum, or a particular piece of documentation or site that I may have missed?

Share This Page