Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 94FBE92F1 for ; Mon, 28 Nov 2011 23:08:01 +0000 (UTC) Received: (qmail 61393 invoked by uid 500); 28 Nov 2011 23:08:01 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 61373 invoked by uid 500); 28 Nov 2011 23:08:01 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 61336 invoked by uid 99); 28 Nov 2011 23:08:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Nov 2011 23:08:01 +0000 X-ASF-Spam-Status: No, hits=-2001.2 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Nov 2011 23:08:00 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 16675A5934 for ; Mon, 28 Nov 2011 23:07:40 +0000 (UTC) Date: Mon, 28 Nov 2011 23:07:40 +0000 (UTC) From: "Shazron Abdullah (Commented) (JIRA)" To: callback-dev@incubator.apache.org Message-ID: <45953051.20110.1322521660093.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <2042843973.20104.1322521540075.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (CB-62) Unable to use JavaScript to redirect to a different page. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13158908#comment-13158908 ] Shazron Abdullah commented on CB-62: ------------------------------------ by: http://github.com/shazron commented September 13, 2011 Unfortunately, this method of changing the url through onclick and document.location will always result as the link being "UIWebViewNavigationTypeOther", even if it has a a target="_self". We check for UIWebViewNavigationTypeOther for anchor tags that have target="_blank" so we re-direct the url to Mobile Safari. There does not appear to be an alternative, save doing this which is equivalent to what you expect: click me by: http://github.com/buddydvd commented September 13, 2011 I believe I have a solution. When you click on an anchor link with target="_blank", the webView actually makes two calls to webView:shouldStartLoadWithRequest:navigationType:. The first call is made with navigationType set to UIWebViewNavigationTypeLinkClicked and second one with UIWebViewNavigationTypeOther. This behavior seems to be unique to anchor links decorated with target="_blank". Here's a relevant blog post: http://longweekendmobile.com/2010/09/14/making-target-_blank-links-work-in-a-uiwebview/ The solution I have in mind is a slightly modified version of the one presented in that post. I will update this thread when I have more information. by: http://github.com/shazron commented September 13, 2011 Randy, window.location shows the same behaviour as the original problem (document.location). by: http://github.com/shazron commented September 13, 2011 buddydvd - confirmed, it generate the two calls as you described (on 4.3 Simulator) for anchor tags with target="_blank". The problem to solve is (reliably) detecting that these two calls in succession constitute a target="_blank". by: http://github.com/buddydvd commented September 13, 2011 @shazron: Thanks for the confirmation. I saw you've setup application tests for the project. Do you think it is ready to include new test cases that simulate clicking on anchor links? by: http://github.com/shazron commented September 13, 2011 @buddydvd - I've had trouble integrating a UIWebView in there for logic tests, but it's possible for application tests (haven't had time to research how yet). I assume the test you are envisioning will require a UIWebView... by: http://github.com/buddydvd commented September 13, 2011 @shazron: Yes, those tests will definitely require automating an UIWebView. Some of the test cases I can think of are: Redirect by sending click event to an anchor without the target attribute. Redirect by sending click event to an anchor with target="_self". Redirect by sending click event to an anchor with target="_top". Redirect by sending click event to an anchor with target="_blank". Redirect by sending click event to an anchor with target="randomValue". Redirect by setting document.location.href And possibly these too: Redirect by calling UIWebView's loadRequest: method (through a plugin). Load remote URL by overriding PhoneGapDelegate's startPage class method. by: http://github.com/apemberton commented October 19, 2011 Any update on this? by: http://github.com/buddydvd commented October 19, 2011 @apemberton: Sorry, I haven't got to work on it because I got side tracked and wasn't sure how to write test cases for it. > Unable to use JavaScript to redirect to a different page. > --------------------------------------------------------- > > Key: CB-62 > URL: https://issues.apache.org/jira/browse/CB-62 > Project: Apache Callback > Issue Type: Bug > Components: iOS > Reporter: Shazron Abdullah > > **Summary:** You can no longer redirect to a different page by updating `document.location.href`. > reported at: https://github.com/phonegap/phonegap-iphone/issues/270 > by: https://github.com/buddydvd > **To reproduce:** Add `www.google.com` to `PhoneGap.plist`'s `ExternalHosts` array. Add an anchor link to `index.html` with its `onclick` handler set to use JavaScript to redirect the webView to`http://www.google.com`. > click me > **Expected:** Clicking the anchor link will load `http://www.google.com` in the embedded webView. > **Actual:** Clicking the anchor link loads `http://www.google.com` in Mobile Safari. > For more info, see: https://github.com/phonegap/phonegap-iphone/commit/9eaeceb2048427f2349cbd862af2507bddf08f77 -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira