Tag Archives: Javascript

Posting HTML Form to External Link in Safari (Cordova/Phonegap)

While developing a fairly data centric Hybrid Application using Cordova, I had a need to exclude AJAX from my form post and send my post request as a standard HTML form post. My main reason for choosing this way over ajax was that I was posting files as well as a long base-64 uri to a C# script on my server. I had a simple aspx form on the servers receiving end that needed to capture the post values coming from the client-side app. I chose this route because users of our applications are in rural areas where their signal strength on their devices we’re so strong. Sending images and base-64 data can be a large pay-load not to mention the other 206 fields coming from the app.

In the end, I wanted to mimic a ajax post while using Formdata which kept me from having to manually create the data object. I wanted the form to post to a new window but in Cordova, the UIWebView takes over and replaces Safari web browser with their view. Below is a code snippet found at StackOverflow that did it for me… I modified my version a bit more to define my parameters but for the most-part this same code snippet got my form to post to an external link on our server.

My form was simple (be sure to use ‘_system’ in your target not _blank!):

<form method="post" action="http://myurl.com/postThis" target="_system"></form>

In CDVWebViewDelegate.m search for “shouldstartloadwith” and replace the contents of the BOOL with:

     (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:
     (NSURLRequest*)request navigationType (UIWebViewNavigationType)navigationType{

     if([[NSString stringWithFormat:@"%@",request.URL] 
         rangeOfString:@"file"].location== NSNotFound) { 
            [[UIApplication sharedApplication] openURL:[request URL]]; return NO;
      BOOL shouldLoad = YES;

Clean and build your application in both CLI then in XCode and test. I ran through a lot of examples of how to post from Cordova to an external form but nothing actually worked. Seem’s this way the best fix for my time and effort. The result was simple enough.




Tagged , , , , ,

CSS3: The Death of Flash


Flash is bulky, memory intense and non-responsive. Device manufactures have already begin to leave it out of their OS avoiding the additional drain on resources. Apple has made it clear they are not interested in supporting Flash, and Adobe has claimed in the past that Apple is a closed system. In fact, Adobe are the ones creating barriers in web interactivity. With the direction our modern markup language HTML5 is going, we can utilize CSS technology to deliver seamless interactivity without the bulk of Flash.

“Symantec recently highlighted Flash for having one of the worst security records in 2009.” (Adobe, Inc., 2012) Besides the resources required to run flash on mobile devices and desktops alike, Flash is memory intense and will reduce battery life on any device, mobile or desktop. In my opinion, Flash was never developed to be flexible for the consumer as it “was designed for PCs using mice, not for touch screens using fingers… Flash websites rely on ‘rollovers’, which pop up menus or other elements when the mouse arrow hovers over a specific spot. Apple’s revolutionary multi-touch interface doesn’t use a mouse” and neither do many of the systems/devices we use today. (Adobe, Inc., 2012)

Sencha put up a nice little note referencing a blog post written by Arne Bench about “Flash Ads vs CSS3 Ads’ and it showed that CSS3 ads are just as graphical in rendering animation as the heavier Flash based ads. Check out the article here! The truth is Flash player is dying. SWF and FLA files will soon be a thing of the past.

I posted a similar title for discussion in my HTML5 group on Facebook and was given a lot of opinions about the use of flash in the future. Many agreed that as we press forward into a device driven world, we will need to re-evaluate our resources on the consumer side. However, many still believed Flash could be used on a desktop level for games and interactive apps. Even with the use of games and interactive applications for the desktop, I still do not think Flash will be the resort – as HTML5 can provide just as much interactivity functionality as Flash once did, on and offline.

Tagged , , ,
%d bloggers like this: