2

Using jquerymobile HTML etc, Android3,4 have tabbed browsing so when I mark my links up with target="_blank" they open in new window but on Android 2 it doesn't work. Is it actually posibble?

It's just otherwise the user when returning to the app has to start all over again lol

1

Try something like this:

<script type="text/javascript">
  $(document).ready(function() {
    var url;
    url = $("a").attr('href');
    $("a").attr("onclick", "window.open('"+url+"'); return false;");
  });
</script>
1
  • one of this issues about opening in a new window in gingerbread is, to actually navigate back to your existing window is something thats pretty complicated from a user-interface perspective. You need to click on the settings button, choose windows, then choose your existing window. its just way less intuitive than A3, A4, iPhone etc Feb 23, 2012 at 2:23
0

Using the .on() function instead of .click() reduces DOMEvents and will help with page speed.

$(document).ready(function() {
    $('body').on('click', 'a[target="_blank"]', function(e) {
        window.open($(this).attr('href'));
        e.preventDefault();
    });
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.