我正在尝试实现描述的 Google 快速按钮 here对于具有两行布局的表格。
快速按钮绑定(bind)在表格行上:
var buttons = document.getElementsByClassName('evtFastbutton');
for (var i = 0; i < buttons.length; i++) {
var fastbutton = new FastButton(buttons[i], function () {
var urlstr = 'xyz';
window.location.href = (urlstr);
});
}
如果单击其中一行,它应该更改上一行或下一行及其本身的背景颜色,并打开一个新页面。
在 Android 或 PC 上使用 Chrome 或 Firefox 时一切正常。
在 iPhone 上的 Safari 中,它不会更改背景颜色,但会打开新页面。
我不确定是什么不起作用,背景颜色的变化还是快速按钮。
有没有人遇到过类似的问题或可能的解决方案?
您可以在这个 fiddle 中找到完整的代码: http://jsfiddle.net/tofeld/9Lu54yrr/1/
PS:我已经尝试过针对这个问题建议的解决方案:Google FastButton clicks twice on iOS
最佳答案
我找到了问题的解决方案。 如所述here在执行更改页面的 javascript 之前,渲染尚未完成。
因此,如果有人遇到类似问题,请尝试执行以下操作:
window.setTimeout(function(){window.location.href=('new/location');},0);
代替
window.location.href=('new/location');
关于javascript - Google Fastbutton 不适用于移动 Safari?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28233175/