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

  • Home
  • SEARCH
  • 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 9202063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:10:09+00:00 2026-06-17T23:10:09+00:00

I am creating a JQM site with multiple pages, using hashtag. e.g. index.html#a On

  • 0

I am creating a JQM site with multiple pages, using hashtag. e.g. index.html#a On one of the page I need to initialize a map, say index.html#map. But it occurred to me that no matter where I place the map initialization script, the script would still be executed when the index.html first load, which I want to avoid.

Although I may associate the map script with some buttons, I also want to be able to load the map when someone load index.html#map directly.

So it comes down to how can I associate JavaScript to a subpage (page with hashtag)?

  • 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-17T23:10:11+00:00Added an answer on June 17, 2026 at 11:10 pm

    I hope all of that pages are part of a single HTML file. If I am correct you don’t need to use this syntax:

    index.html#map
    

    this one will be enough:

    #map
    

    Lets say this is your HTML:

    <!DOCTYPE html>
    <html>
    <head>
        <title>jQM Complex Demo</title>
        <meta name="viewport" content="width=device-width"/>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
        <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>    
    </head>
    <body>
        <div data-role="page" id="index">
            <div data-theme="a" data-role="header">
                <h3>
                    First Page
                </h3>
                <a href="#second" class="ui-btn-right">Next</a>
            </div>
    
            <div data-role="content">
    
            </div>
    
            <div data-theme="a" data-role="footer" data-position="fixed">
    
            </div>
        </div> 
        <div data-role="page" id="second">
            <div data-theme="a" data-role="header">
                <h3>
                    Second Page
                </h3>
                <a href="#index" class="ui-btn-left">Back</a>
            </div>
    
            <div data-role="content">
    
            </div>
    
            <div data-theme="a" data-role="footer" data-position="fixed">
    
            </div>
        </div>    
    </body>
    </html> 
    

    Then to associate a javascript to a certain page use this syntax:

    $(document).on('pagebeforeshow', '#index', function(){       
        alert('Index page');
    });
    
    $(document).on('pagebeforeshow', '#second', function(){       
        alert('Second page');
    });
    

    Here’s a working jsFiddle EXAMPLE.

    Also take a look at my personal blog ARTICLE, it will help you to deal with jQuery Mobile page events. Or take a look at my other ANSWER.

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

Sidebar

Related Questions

I'm creating a Mobile App with JQM and JSP I'm using Bookmark bubble to
I am creating a JQM webapp and need to add dropdown menu to the
I am creating a mobile app using JQM and trying to center radio buttons
Creating a website using simple html(not html5) and css but got stock in mouseover
Creating a google map with store locations within 50 miles of user entered address.
Creating a simple RPG game, first time using XNA. Trying to get my character
Creating an iPhone App in xCode, and I need to populate it with data
Creating a browser based single-page browser based RIA. Would like to make use of
Creating simple php login scripts is easy, with simple one table mysql integration. I
Creating a popup window from main page with window.open, the child/popup page uses the

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.