Getting a link to open in a new window on Android 2

南笙酒味 提交于 2019-12-11 03:47:43

问题


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>



回答2:


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();
    });
});


来源:https://stackoverflow.com/questions/9355280/getting-a-link-to-open-in-a-new-window-on-android-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!