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 9255901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:48:51+00:00 2026-06-18T11:48:51+00:00

I have a index.html file with following syntax <!DOCTYPE html> <html> <head> <meta charset=utf-8>

  • 0

I have a index.html file with following syntax

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<a href="occassion.html">
  <img class="frametoicon" src="img/occasion.png" />
</a>
</body>
</html>

then I have occassion.html page which has body onload function as follows

  <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
<title>Occassion</title>
<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/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script>

    function loaded() {
        alert("hii");
    }
</script>
</head>
<body onLoad="loaded()">
</body>
</html>

but onload function is not firing up….if I try to refresh the page (occassion.html) then onload function gets fired up… why it is not working when navigated from index.html?

If I remove the jQuery files, then it works as expected….what I am missing to add?

This is also not working

 $(document).ready(function () {
        loaded();
    });

Edit

I added

 <script>
    $(document).bind("pagechange", function (event, data) {
        console.log(data);
        var toPage = data.toPage[0].id;
        alert(toPage);
        if (toPage == "page2")
            alert("hello");
    });
</script>

and put the following in occassion.html

<div data-role="page" id="page2">
 hello
 </div>

To my surprise not even the alert(hello) is firing but also hello is also not displayed and alert(topage) is coming empty..

How is it? what’s missing

  • 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-18T11:48:52+00:00Added an answer on June 18, 2026 at 11:48 am

    jQuery Mobile uses AJAX to pull pages into the DOM, that’s how it can transition between pages. When jQuery Mobile does this, there is a good chance it’s doing it after the window.load event fires, so that event will generally not fire unless you refresh the page (then window.load will fire again). It seems possible that a user could click a link and have it load before the window.load event fires, but I wouldn’t expect that to be the norm.

    The fix is to use jQuery Mobile specific events, in this case you’re probably looking for pageload/pagecreate/pageinit, see documentation about them here: http://jquerymobile.com/demos/1.2.0/docs/api/events.html

    Here is a quick example of how this could work (this code would be located centrally and included in each document):

    $(document).on("pageinit", "#occasions", loaded);
    

    Note that #occasions would be the data-role="page" element in the occasions page.

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

Sidebar

Related Questions

I have the following file structure: |- index.html vendor |- jquery.min.js (some libraries) js
I have the following index.html page set-up: <html> <head> </head> <body> <div id=container> <div
I have an index.html.erb file with the following: <%= render @users %> This renders
I'm using this tooltip: http://flowplayer.org/tools/demos/tooltip/index.html I have the following lines in my html file:
I have a static site with the following file/folder structure: index.html /foobar/ index.html bob.html
I have Javascript function defined in the main index.html file. One part of this
I have an upload script that write a index.html file, I modified it to
I have a PHP script (index.php) that includes an index.html file in a sub-directory
I have a template in joomla without index.php I only have index.html, css file,
I have activated the IIS package for windows, and, I created an index.html file

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.