Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8635435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:58:26+00:00 2026-06-12T09:58:26+00:00

On a document ready field of jquery mobile file, I am waiting for a

  • 0

On a document ready field of jquery mobile file, I am waiting for a link click. Then following function is executed,

 $(document).ready(function() {

   $("a").click(function ()
   {  
     var t = $(this).attr('href');
     alert(t);
   });
});

On a native webview iOS device doesn’t work while on a normal browser does! On a browser, alert returns href properly, but on native returns just a single #. Strange… Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:58:27+00:00Added an answer on June 12, 2026 at 9:58 am

    Ran into this as well on my iOS6 iPad2 running my HTML5 homescreen app that is under construction. The short of it is there appears to be a bug in either iOS or JQuery/JQueryMobile (which I currently use). After troubleshooting for an hour here is what I found:

    1. the event.target [in your example $(this)] the href returned when in Safari or FullScreen Homepage app sometimes returns # and sometimes returns the correct href.

    2. The times it returns the href I’m expecting are few and far between however the pattern seems to be that if you clean at the bottom of the image near the a tag’s text (assuming you put text by the image in the a tag. Then it sometime returns the href.

    So I tried a number of things and no matter what I tried get the href value is inconsistent on iPad with JQM. So what I did (at least for now) is added data-href markup in the a tag. So for example I have the following markup (with some pseudo markup)

    <div>
    <a href="./home.hmtl" data-href="./home.html" data-ajax=false data-transistion=none"><img {YOUR IMAGE INFO HERE!} /></a><br/> Label-Text-Under-Image
    </div>
    

    Then in JavaScript I can simply do either:
    $(this).attr(‘data-href’) like in you example though I didn’t test it with your example
    OR what I did was the following so as to affect all the a tags in my page (which is what I wanted to do)

    $(document).on(
            "click",
                "a",
                function (event) {
                    if (event.target instanceof HTMLImageElement) {                    
                        var aUrl = $(event.target).parent().attr("data-href");
                        if (typeof aUrl != 'undefined') {
                            event.preventDefault();
                            alert(aUrl);
                            window.location = aUrl;
                        }               
                    }                            
                }
            );
    

    The real magic in my case was:
    $(event.target).parent().attr(“data-href”);
    where I got the data-href which is consistently returned correctly on desktop and iPad. Of course the my final version I removed the alert call but that’s what got me working on an iPad with JQM and allow me to keep my homescreen app from launching Safari. BTW I’m using JQM 1.1.0 as I haven’t had a chance to get the latest… not sure if they have a fix for it in the newer version.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this JQuery: $(document).ready(function() { $(#generate).click(function() { var texts = []; alert(); $(form
jQuery(document).ready(function() { jQuery(#bfCaptchaEntry).on(click, function(){ jQuery(#bfCaptchaEntry).css(background-color, #FFFFFF); }); jQuery(#bfCaptchaEntry).on(blur, function(){ jQuery(#bfCaptchaEntry).css(background-color, #CC0000); }); }); This
I have the following jQuery code: $(document).ready(function(){ var ac_config = { source: autocomplete-delta.php, select:
This code still sets the field to today's date <script type=text/javascript> $(document).ready(function () {
$(document).ready(function() { $('#username').focus(function() { $(this).val(''); }) $('#username').blur(function() { var l = $(this).val.length; if (l
jQuery(document).ready(function ($) { $('body').keypress(function (e) { alert(e.which); }); }); This will pop up an
I have the following jquery code: $(document).ready(function() { $(#build_table, a.coursename, .Start Date, .Book Title,
I've got the following jQuery (I've got it wrapped in the document ready function
This is my code: <script type=text/javascript src=js/jquery-1.5.1.min.js></script> <script type=text/javascript src=js/jquery.validate.js></script> <script type=text/javascript> $(document).ready(function() {
I have: $(document).ready(function () { jQuery(function ($) { $(#ClientID).mask(999-999999999); } } Now this mask

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.