我目前正在开发一个网页,当被访问时,它会在移动safari中打开另外两个网页。
唯一的问题是,当加载新选项卡时,浏览器关注的是要加载的最后一个选项卡。
我试过设置Safari的“在后台打开链接->”,但这似乎只给了你一个选项:按住一个链接,然后手动选择在后台打开该链接(因此仍然专注于当前页面)。
有没有办法在Mobile Safari中使用javascript自动打开网页链接,而不会失去对当前网页的关注?
下面是我当前使用的代码的一个示例。
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<html>
<head>
</head>
<body>
<a class="site" href="bbcNews/www.bbc.co.uk/news/index.html" target="_blank">Open Tabs</a>
<script>
$('a').each(function () {
var clk = document.createEvent("MouseEvents");
clk.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, true, 0, null);
this.dispatchEvent(clk);
});
</script>
</body>
</html> 发布于 2016-01-14 02:25:30
很长一段时间以来,我一直在使用这种逻辑来表示“出栈”。希望这对您有用:-Basic的想法是在新选项卡中打开页面本身,同时将“旧”选项卡/页面重定向到其他位置
function popunder_redirect(){
window.open("#tab");
window.location="http://redirecturl.com";
}现在,正如您所看到的,在原始页面链接旁边有散列链接(#tab),您可以将其用作某种伪历史记录,通过检查页面加载来调整您的javascript或其他页面进度:
jQuery(document).ready(function(){
var hashValue = window.location.hash; //get hash value
//check for hash value
if (hashValue!=undefined && hashValue=="#tab")
{
//display progressed page}
else{
//display start page
}
});https://stackoverflow.com/questions/26633129
复制相似问题