jQuery Mobile URL converting hash (#) to %23 on Android browser

扶醉桌前 提交于 2019-12-08 05:28:29

问题


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>

回答1:


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);



来源:https://stackoverflow.com/questions/9798731/jquery-mobile-url-converting-hash-to-23-on-android-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!