我试图通过这款出色的服务Google Mobilizer“动员”我的部分网页上的链接:http://www.google.com/gwt/x?u=
有没有办法为div或元素中的所有链接添加前缀,所以而不是链接是site.com/link它会变成http://www.google.com/gwt/x?u=site.com/link?
我认为这样的事情可能有用:
if (window.location == $LINK)
window.location = "http://www.google.com/gwt/x?u=" + $LINK;
我只是不确定如何编码。如果你知道它是如何完成的,我将非常感激!
答案 0 :(得分:0)
我认为这对你有用:
Mobile_Detect.php
将此代码放在您要重定向的每个页面的开头
<?php
include('Mobile_Detect.php');
$detect = new Mobile_Detect();
if ($detect->isMobile()) {header('Location: http://www.google.com/gwt/x?u=http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"],PHP_URL_PATH . '');}
?>
我使用this site进行了测试,效果很好
答案 1 :(得分:0)
我写了Google Mobilizer bookmarklet as I had a itch to scratch。
您可以根据自己的要求调整代码。