Skip to content
Snippets Groups Projects
Commit 379c77af authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Cordova: Prevent open external urls inside the app

parent c9d30822
No related branches found
No related tags found
No related merge requests found
Meteor.startup ->
return unless Meteor.isCordova
platform = device.platform.toLowerCase()
# Handle click events for all external URLs
$(document).on 'deviceready', ->
$(document).on 'click', (e) ->
$link = $(e.target).closest('a[href]')
return unless $link.length > 0
url = $link.attr('href')
if /^https?:\/\/.+/.test(url) is true
switch platform
when 'ios'
window.open url, '_system'
when 'android'
navigator.app.loadUrl url, {openExternal: true}
e.preventDefault()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment