The standard jQuery Mobile CSS styling does not seem to be working across various browsers, extensive testing has been conducted

I'm currently experimenting with jQuery Mobile to enhance my skills, but I'm facing issues with applying the basic CSS styling. I have included the css link from the jQuery Mobile website and ensured that I am connected to the internet. However, even after attempting to load the css locally into html, the styling still fails to apply.

Below is the code I have used for testing:

<!DOCTYPE html>
 
<html>
 
<head>
 
<meta charset="UTF-8">
 
<title>2test</title>
 
<meta name="viewport" content="width=device-width, initial-scale=1">
 
 <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />

  <script src="http://code.jquery.com/jquery-1.4.5.min.js"></script> 
  <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
 
</head>


<body>

<div data-role="page">
<div id="header" data-role="header">
    <h1>My Photos</h1>
</div>

<article data-role="content">
    <ul data-role="listview" data-filter="true">
        <li>
            <a href="#">
            <h1>Miniature Doberman Pincher</h1>
            
            <p>This is what happens when a
            friend brings a dog to the studio.</p>
            </a>
        </li>
        <li>
            <a href="#">
            <h1>Gummy Bears</h1>
            
            <p>Three different poster boards...mirror for reflection,
            black for background white for highlights</p>
            </a>
        </li>
    </ul>


</article>

<footer data-role="footer" data-position="fixed">
    <nav data-role="navbar">
        <ul>
            <li><a href="#">Home</a></li>
            <li><a href="#">Photos</a></li>
            <li><a href="#">Info</a></li>
        </ul>
    </nav>
</footer>
</div>


</body>


</html>

Here is how the output appears on desktop Chrome 45 (EDIT: screenshot old, images since removed):

https://i.sstatic.net/bySEC.png

and this is the display on my android device Chrome 45 (accessed from hosted site):

https://i.sstatic.net/NkPR3.png

Both outputs do not exhibit the expected mobile-friendly aesthetics of jQuery Mobile's default styling. What could possibly be missing in my implementation?

Answer №1

When checking the console, I noticed the following errors:

Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME http://code.jquery.com/jquery-1.4.5.min.js Failed to load resource: the     server responded with a status of 404 (Not Found) jquery.mobile-1.4.5.min.js:3 Uncaught TypeError: Cannot set property 'mobile' of undefined

It seems like JQM is struggling to parse local file paths, causing the JavaScript to fail. To resolve this issue, consider using relative paths instead of referencing local files.

Furthermore, it appears that some of your JQM paths may be incorrect:

<!-- add this link here -->
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<!-- remove your link here -->
<!--  <script src="http://code.jquery.com/jquery-1.4.5.min.js></script> -->

Refer to jQuery Mobile getting started error for more information on including jQuery before JQM or utilizing a bundle.

In addition, there are other issues with your implementation. JQM manipulates DOM/HTML extensively and follows a structured approach different from other style frameworks. Reviewing the documentation would help in understanding JQM better.

According to

In jQuery Mobile, a page consists of an element with a data-role="page" attribute. Within the "page" container, valid HTML markup can be used, but typically includes divs with data-role="header", class="ui-content", and data-role="footer". The minimum requirement for a page is the page wrapper for navigation system support, everything else is optional.

Getting started with JQM can be tricky - make sure you have the required page div. It might be beneficial to start by copying examples and then customize as needed, ensuring to wrap content inside a page div for styling purposes.

<div data-role="page">
...
</div>

To see a working version of your example without images, visit http://jsfiddle.net/shotgundriver/8mb0rzhy/

Answer №2

While encountering the console error "Uncaught Security Error Failed to Execute Replace State on History..." in Chrome, I decided to search for solutions on Stack Overflow. It appears that Chrome's security features might be hindering the loading of content from an external source.

To troubleshoot, I attempted to load the page from a web server and interestingly, the CSS is successfully rendering in Chrome. Moreover, Firefox was able to render the page correctly when accessed locally. This issue seems to be specific to Chrome, preventing local testing.

For more information, you can refer to this Stack Overflow thread: Uncaught SecurityError: Failed to execute 'replaceState' on 'History': cannot be created in a document with origin 'null'

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

HTML code for adding a dropdown menu inside a table cell

I am trying to set up a table where one cell functions as a dropdown menu. The data.field is being fetched from the backend and I want it to be displayed during rendering. Additionally, a fList is also retrieved from the backend. When a user clicks on th ...

Is it considered the most appropriate method to implement a dynamic web page refresh by utilizing PHP, HTML, and AJAX in order to read a

My PHP page currently displays data from a database in tables, but the information is frequently changing. This means that the entire page has to be reloaded every few seconds. I am looking for a way to query the database and update only the section of HT ...

What could be causing the compatibility issue between fr units and grid-template-rows in CSS grid?

I'm having trouble getting the row height to change using fr units in my grid-template-rows. It seems to work fine with other units like pixels, but not with fr. I find it confusing that the fr units work perfectly fine with grid-template-columns, so ...

Is it possible to dynamically adjust the container size based on its content with the help of *ngIf and additional directives?

I have a single-image container that I need to resize when editing the content. The size should adjust based on the incoming content. See the images of the containers below: Image 1: This is the container before clicking on the edit button. Image 2: This ...

When an anchor surrounds a div tag, white borders will appear

Lately, I've encountered an unusual issue. My buttons are created using div tags with rounded edges and border colors defined in the CSS. To link them to specific destinations, I encapsulated them within <a> tags. The problem arises when the li ...

Maintain the visibility of the Jquery modal regardless of page loading

Hello, I am just getting started with jQuery and have encountered an issue. When I try to display a jQuery modal on the click of an Upload button, it disappears immediately because of the page load. I would like the modal to stay visible until a button wit ...

Reload a tab on an ajax-enabled webpage

I am currently facing an issue with refreshing a tab instead of the entire page using Ajax. The specific tab in question involves deleting credit cards. When I select the credit card I want to delete and confirm, I use "window.location.reload();" to refres ...

The CSS method for changing the content URL is experiencing difficulties in Firefox

Css: .woocommerce-placeholder.wp-post-image { content: url("DSC0926-1.jpg"); } /*for firefox*/ .woocommerce-placeholder.wp-post-image::before { content: url("DSC0926-1.jpg"); } HTML <img src="placeholder.png" alt="Placeholder" class="woocomm ...

Unable to fix position: sticky issue following Angular 15 update

Following the angular material update to version 15, many of us experienced issues with CSS changes breaking. This also affected legacy code that included sticky headers. <div class="row"> <div class="col-12"> <di ...

Seeking a light-weight, text-rich editor specifically designed for use on our enterprise website. This editor should be even lighter than TinyMCE

I am in search of a lightweight text editor for an enterprise website, lighter than tinymce with basic buttons for the comment form. It is imperative that the editor also functions properly in IE6. So far, I have tried cleditor 15KB, but it has an issue in ...

What could be causing the dysfunction of the jQuery class adding function?

I'm new to using jQuery and I'm trying to add a class to the 'a' tag when the 'li' tag is clicked. However, it doesn't seem to be working as expected. $('.nav-item').click( function() { $(".nav-item a").re ...

A guide on looping through a JSON array that has the specific structure

I am currently working with a JSON structure that looks like this: Object data: Array[1] 0:Object categories: Object cat: namecat cat2: namecate2 errors: Object err1: error1 er ...

Is it possible to fetch JSON data in PHP without having to encode it with json_encode()?

I've been trying my luck, but I'm curious if it's possible to retrieve JSON data if it's not encoded server-side with PHP. For instance, if I were to simply output some data like this: echo '{"subscriptions": [{"subscribe":"' ...

"Is there a way to reverse the action of $( "button" ).remove()

Currently, I have implemented JQuery's $( ".button" ).remove(); function to get rid of all the buttons on my webpage immediately after a user clicks the print PDF button that changes the HTML page into a PDF. Nevertheless, once this process is done ...

Enhancing Form Spacing with Bootstrap

I have been working on a form design, but I am now facing alignment issues. The problem is more noticeable on larger screens compared to smaller ones. The main issues I am encountering include extra spacing in the social links section even though there ar ...

The issue of the responsive navigation bar overlapping the header and navigation links not functioning properly

Hello everyone, I need some help with my website! I can't seem to find the answer on my own. I'm currently working on making my website responsive, but I've run into an issue with the mobile navigation on phones. The navigation links are ov ...

Issues with jQuery horizontal sliding gallery functionality

My attempt at creating a jQuery sliding video gallery is not working as I hoped. Instead of scrolling through the images when clicking arrow buttons, the entire div moves left or right depending on the direction. HTML: <div id="videocontainer"> & ...

The click functionality is not functioning properly within the .each() loop

For my event handler, I am trying to use click() but it doesn't seem to be working. Here is the code snippet: $('.ajax-close').click(function( event ){ event.preventDefault(); alert('hi'); $( ' ...

How can I utilize JQuery to dynamically refresh a dropdown menu?

My dropdown list is initially empty: <div> <label>Boarding Point </label> <select title="Select pickup city" id="boardingDropdown"> </select> </div> I am trying to popula ...

Rearrange list items by dragging and dropping

Here is the HTML and TypeScript code I have implemented for dragging and dropping list items from one div to another: HTML: <div class="listArea"> <h4> Drag and Drop List in Green Area: </h4> <ul class="unstyle"> <l ...