jQuery Mobile的URL转换哈希(#),以23%的Andr​​oid浏览器浏览器、URL、Mobile、jQuery

2023-09-06 16:54:19 作者:持伞猫

我使用jQuery Mobile的多页模板为我的网站,但是当我访问从Android浏览器的网站就无法正常工作。

问题是,浏览器标记转换为 23%

例如,我可以访问此链接 www.domain.com/abc.php?id=1234#show_map 在iPhone而Android这样表示此链接: www.domain.com/abc.php?id=1234%23show_map

我该如何解决这个问题?我应该创建新的页面,而不是散列标签页或如何可以添加例外Android的浏览器?

感谢

更新:这里是code,这并不在Android上工作,但工作在其他地方:

 <脚本类型=文/ JavaScript的>        window.done_mapping = FALSE;        应急=功能(){            如果(window.done_mapping)返回true;            window.location.href ='#roast_map';            window.location.reload();        }        contingency_email =功能(){            如果(的document.getElementById(邮件))返回true;            window.location.href + ='#电子邮件';            window.location.reload();        }    < / SCRIPT>    < D​​IV数据角色=内容>        &所述; UL数据角色=列表视图数据嵌入=真的数据主题=c的数据dividertheme =一个>            <李班=goMap><有关地图&LT查看; A HREF =#roast_map数据过渡=幻灯片的onclick =应急();&GT / A>< /李>            <李班=goMap>< A HREF =#电子邮件数据过渡=幻灯片的onclick =contingency_email()>电子邮件结果片剂; / A>< /李>        < / UL>    < / DIV> 

解决方案

有是一个jQuery EN code /德code方法,你应该使用EN code包含特殊字符的URL。例如:

VAR URL ='www.domain.com/abc.php?id=1234#show_map';变种EN codedUrl = EN codeURIComponent(URL);

I am using jQuery Mobile Multiple-Page template for my website but when I visit the website from Android browser it is not working.

The problem is that, the browser converting # tag to %23.

For example I can visit this link www.domain.com/abc.php?id=1234#show_map in iPhone but Android shows this link like this : www.domain.com/abc.php?id=1234%23show_map

How can I solve this problem? Should I create new page instead hash tag page or how can I add an exception for Android browsers?

Thanks

UPDATE: Here is the code that doesn't work on Android, but works everywhere else:

    <script type="text/JavaScript">
        window.done_mapping=false;
        contingency = function() {
            if(window.done_mapping) return true;
            window.location.href='#roast_map';
            window.location.reload();
        }
        contingency_email = function() {
            if(document.getElementById("email")) return true;
            window.location.href+='#email';
            window.location.reload();
        }
    </script>

    <div data-role="content">
        <ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="a">
            <li class="goMap"><a href="#roast_map" data-transition="slide" onclick="contingency();">View on map</a></li>
            <li class="goMap"><a href="#email" data-transition="slide" onclick="contingency_email()">E-mail Results</a></li>
        </ul>
    </div>

解决方案

There is a jquery encode/decode method you should use to encode a url that contains special characters. for example:

var url = 'www.domain.com/abc.php?id=1234#show_map'; var encodedUrl = encodeURIComponent(url);