Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems opening new window Javascript in same window



Hi,

I'm running in the following problem. I use a webview as a built-in webbrowser within my app. Given the fact that it is an iTunes like applications I don't allow the opening of new windows. Instead when a new window request comes in I just cancel it and open the requested URL in the same window.
There's one situation however where this doesn't seem to work.


Take this webpage in Safari: http://ucelinks.cdlib.org:8888/sfx_local?sid=Entrez:PubMed&id=pmid:16636135
If you click on the first "Go" image/button labelled with "Highwire press free" you'll notice a new window is created and a webpage is loaded in there.
However I can't get the contents to load in the same window that the original request came from.


The problem is in the way the links are created, they are in a form that is triggered by a javascript when you click the link (don't ask why!?!):

<form METHOD=POST ACTION="http://ucelinks.cdlib.org:8888/sfx_local/cgi/core/sfxresolver.cgi " NAME="basic1" TARGET="newwin">
<A HREF="javascript:openWin(this);window.document.basic1.submit();"><IMG SRC="/sfx_local/img/sfxmenu/go.gif" BORDER="0" HSPACE="16" ALT="GO"></A>
In my delegate methods I have the following:


- (WebView *)webView:(WebView *)sender createWebViewWithRequest: (NSURLRequest *)request{
NSLog(@"createWebViewWithRequest: %@", request);
return sender;
}


- (void)webView:(WebView *)sender decidePolicyForNewWindowAction: (NSDictionary *)actionInformation request:(NSURLRequest *)request newFrameName:(NSString *)frameName decisionListener: (id<WebPolicyDecisionListener>)listener{
NSLog(@"New window request: %@, actioninfo: %@", request, actionInformation);
//DO NOT ALLOW
[listener ignore];
//INSTEAD Open new window in this window
[[webView mainFrame] loadRequest:request];
}


What I get is that first method is called but with a NULL request. And since the request is NULL I can't figure out when this is whole thing is actually happening if the user also browses other types of pages.
The second method is not even called.


Now I can see kind of why, first the javascript will just create an empty window, and then the second javascript should submit and probably open the real link in that new window, I guess by referring to it's frame name (or am I wrong?).

So the question is how to catch that call and how to redirect it to my existing webview frame?
Many thanks for your help!
Alex




**********************************************
         ** Alexander Griekspoor  PhD **
**********************************************
          mekentosj.com

 Papers - Your Personal Library of Science
 2007 Winner of the Apple Design Awards
         Best Mac OS X Scientific Solution
         http://www.mekentosj.com/papers
**********************************************

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webkitsdk-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webkitsdk-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.