Google 快速按钮无法在移动版 Safari 上运行?
Google Fastbutton not working on mobile Safari?
我正在尝试使用两行布局为 table 实现描述 here 的 Google 快速按钮。
快速按钮绑定在 table 行上:
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');
我正在尝试使用两行布局为 table 实现描述 here 的 Google 快速按钮。
快速按钮绑定在 table 行上:
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');