Archive for November, 2012

[[UIApplication sharedApplication] openURL:url] not working on mailto

November 17, 2012 Leave a comment

*Hack warning*: This is not an elegant or nice solution, so feel free to berate me for damage to your eyes ūüôā

If you are using PhoneGap with iPhone, then you have noticed that external urls don’t open unless you modify

shouldStartLoadWithRequest, This works fine with http:// and https:// urls, but I’ve noticed that it didn’t work with tel: or mailto: links. Despite millions of posts on the internet saying it ‘should’ work. I found a horrible hack that avoids this problem, by creating a HTML page on my server, with the content:

<script language=”javascript”> function getParameterByName(name) { name = name.replace(/[\[]/, “\\\[“).replace(/[\]]/, “\\\]”); var regexS = “[\\?&]” + name + “=([^&#]*)”; var regex = new RegExp(regexS); var results = regex.exec(; if(results == null) return “”; else return decodeURIComponent(results[1].replace(/\+/g, ” “)); } var url = getParameterByName(“url”); window.location.href=url; </script>

Which, very simply, means that you can send a user to – sending the user to safari, then the mail client immediately afterwards.

Feel free to throw up your lunch now.


Categories: Uncategorized

Incorrect PFS free space information for page

November 15, 2012 2 comments

This is just a personal experience, so if this destroys your house or eats your dog, then don’t blame me.

If you run a DBCC CheckDB on your SQL server database, and get an error such as

Incorrect PFS free space information for page (1:7394) in object ID 60, index ID 1, partition ID 281474980642816, alloc unit ID 71776119065149440 (type LOB data). Expected value   0_PCT_FULL, actual value 100_PCT_FULL.

Then, you can repair this error using

DBCC checkdb (‘xxxx’, repair_allow_data_loss);

What this command does, is delete any erroneous pages, which removes the error, but will also delete any data contained in the erroneous pages. If the affected data can be sacrificed, then you can use this to recover the rest of the database.


Categories: Uncategorized

Selectively prevent vertical scrolling in Phonegap app.

November 13, 2012 Leave a comment




A battle I’ve often fought is the vertical scroll in Phonegap. iOS sees the app as a browser window (UIWebView), and wants to treat it as such, and your clients and users see it as a static app, with fixed navigation elements ontop of scrollable content.

On pages where the content does not need to be scrolled at all then you just need to call preventDefault on touchmove event.

document.addEventListener(‘touchmove’, function (e)
if (!IsDraggablePage(e))
}, true);

Note, that I have used a function call to “IsDraggablePage”, this method can be used to selectively decide if the page can be scrolled or not. Typically, a page where all the content fits without scrolling, then you can disable scrolling, if the content doesn’t, or may not always fit, then you should enable scrolling.

function IsDraggablePage(e)
return true;
return false;

This function, isDraggablePage, checks an attribute “draggable” of the page, and if it is set to true, then the page can be dragged.

All well and good, until you hit this problem, on a page that needs to be draggable, it appears that the navigation bars can be dragged out of place

This is caused by the UIWebView Bounce feature of iOS, and in order to remove it, then you have to change some of the underlying Cocoa code, namely Classes > AppDelegate.m

Scroll to webViewDidFinishLoad, and enter the following line of code before the return statement:

[[theWebView.subviews objectAtIndex:0] setBounces:NO];

This means that, when you scroll beyond the bounds of the UIWebView, it will not bounce back to position, it will just stop suddenly, leaving your navigation in place.

Categories: Uncategorized

Open link in external browser using Phonegap Webworks for Blackberry

November 7, 2012 2 comments

If you are developing apps for BlackBerry using PhoneGap / Webworks for Blackberry, then you have probably noticed that ¬†if you add a url to an external website, such as <a href=””>Google</a&gt;, then the destination website gets loaded within the frame of the app, giving a poor user experience, and no way to return to the app, apart from closing the app.

The solution is not obvious, since you have to use Webworks API (which is not cross-platform, it’s BlackBerry only).

use the following code when itializing JQuery

$(‘a[target=”_blank”]’).live( ‘click’, function()
if ( window.blackberry )
alert( ‘Loading website: ‘ + $(this).attr( ‘href’ ) );
var args = new blackberry.invoke.BrowserArguments( $(this).attr( ‘href’ ));
blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);
return false;
return true;

Then IMPORTANTLY add the following lines to the config.xml

<feature id=”” required=”true” version=”″/>

<feature id=”blackberry.invoke”/>
<feature id=”blackberry.invoke.BrowserArguments” />

<access uri =”*”/>

I have heard that this invocation mechanism may change for BlackBerry 10 / Playbook, which I am going to test soon.

Categories: Uncategorized