Gokhan Arik
Gokhan Arik

Reputation: 2766

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

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>

Upvotes: 1

Views: 1668

Answers (1)

Nando
Nando

Reputation: 223

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

Upvotes: 1

Related Questions