问题
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