Display a still image in cases where the browser does not support 3D images

I need to display a 3D image in my HTML page if the browser supports canvas, otherwise I want to show a static image. The image should be loaded dynamically when the page loads.

<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
    <meta charset="utf-8">
    <title>Hello Modernizr</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
    </script>
    <script src="modernizr.js"></script>
    <script>
        if (Modernizr.canvas) 
        {
            $(document).ready(function()
            {
                $("p").show();
            });
            alert("This browser supports HTML5 canvas!");
        } 
        else 
        {
            $(document).ready(function()
            {
                $("p").hide();
            });
        }
    </script>
</head>
<body>
    <p>If you click on the "Hide" button, I will disappear.</p>
</body>
</html>

Answer №1

To incorporate the image, simply include it within your else condition as illustrated in the example code provided. It is recommended to modify a div element instead of a paragraph.

} else {
  $(document).ready(function(){
    $('div').html('<img src="yourImg.png" />');
  }
}

Answer №2

update the javascript code

so that it shows an image in all web browsers

<div class="cont_machines_3d">
    <div class="cont_3d">

    <iframe height="600" scrolling="auto" src="3d/3dimage.html" width="800">
    </iframe>
    </div>
    </div>

modify it to display the image specifically in Internet Explorer

<div class="cont_machines_3d_ie"><img src="/3d/images/img.jpg" width="800" /></div>
</div>

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

Tips for showing text on top of a responsive image using CSS

I am working on a layout with 4 columns, each containing images of different sizes followed by a hover effect with an absolutely positioned mask. The width of the mask is currently exceeding the width of the images. Is there a way to ensure that the mask ...

Trouble with table class functionality persists following insertion of SQL database

After successfully setting up the table layout and connecting it to a database, I encountered an issue with the class not working as expected. Despite being able to retrieve records and display them in the table, the desired layout was missing. <bo ...

Adjust the size of the title font and modify the background colors

One of my titles looks like this: <a title="I am your title"/> The default background color is yellow Take a look at this image which can help illustrate what I'm asking about Is there any way to change the background color and increase the ...

Caution: It is important for each child within a list to have a distinct "key" prop when using react-input

I'm currently facing an issue with the following code snippet: {array.map((item) => ( <> <input key={item.id} type="checkbox" /> ...

Solving the Angular form glitch: error message not displaying

I am facing an issue with my simple form where I am not able to display errors related to the fields. <html lang="en" ng-app="MyApp"> <head></head> <body ng-controller="AppCtrl"> <form name="myForm" id="myForm"& ...

Using CSS or HTML to create a link or anchor that corresponds to specific image coordinates

I am envisioning something akin to a reverse image map. I have a sizable image (measuring over 2000x2000) and I would like to provide clickable links to specific coordinates on the image. Essentially, I want users to be able to click on certain items wit ...

Generate pre-set components using fundamental building blocks

Can I predefine some props for components? In my Vuetify example, let's say I want to customize the v-btn component with specific props. This custom implementation would act as a child component while still providing all the functionalities of the par ...

Javascript Developer Platform glitches

Describing this issue is proving difficult, and I have been unable to find any solutions online. My knowledge of Javascript and its technologies is still quite new. I am currently working on a web application using NodeJS, Express, and Jade that was assig ...

Having trouble accessing the POST RESPONSE json in ReactJS and NodeJS

I have set up my own API server that is connected to a MySQL database. Whenever I send a request to the server, everything seems fine. I can see the input from the browser and the output from the database in the console. However, I am unable to see any new ...

Simultaneous display of icon and text on Bootstrap toggle button

Currently, I am utilizing Bootstrap 3 along with Jquery. Within my coding structure, there is a button that holds an icon within a span tag (specifically using the glyphicon provided by Bootstrap). <button id="swapArchived" class="btn btn-default btn-s ...

Problem saving videos when using the right-click function

Hello, I am currently working on retrieving videos from a database, but I have encountered an issue with the video saving option. When a user right-clicks on the video, they are able to save it in their system's storage. What I would like to achieve ...

Here's how to use the useState hook directly in your React components without

Currently, I am using the code snippet below to import useState: import * as React from 'react' import {useState} from 'react' I wanted to see if there is a way to condense this into one line, so I attempted the following: import * a ...

Is it possible to run quirks mode in one frame while running standards mode in another?

Back in the IE6 days, I developed an old application that relies on frames instead of iframes and runs in quirks mode. Now, I'm wondering if it's possible to have one frame remain in quirks mode while another operates in standards mode when using ...

What is the process for transforming a block of plain text into a formatted text with multiple paragraphs while tracking the word count

I am faced with the task of transforming a simple text consisting of 5000 words into multiple paragraphs, each containing 1000 words. Is there a way to accomplish this? If so, I would greatly appreciate any guidance or assistance you can provide. ...

Is it possible to stop and start the animation in jQuery?

Currently utilizing jquery for object animation. Searching for a method to halt animation on mouseover and continue once the mouse moves away. Is there a way to achieve this functionality? ...

What are the steps to reinitialize Grunt in a Yeoman project?

My Grunt installation seems to be causing a lot of errors out of nowhere. I'm using Yeoman to scaffold my app, but today when I run Grunt Test, I get the following error messages: Loading "autoprefixer.js" tasks...ERROR >> Error: Cannot find mo ...

When I resize the screen size, my multiple item carousel in Bootstrap is failing to adjust and collapses

Whenever I try to resize the output screen, the carousel collapses and the last few items disappear. I really need the carousel to stay intact even when resizing. Can someone please assist me with this issue? Link to my CodePen ResCarouselSize(); $(w ...

Generating various arrays of data

I am currently facing an issue with creating separate datasets based on the month value. Despite my efforts, all month values are being combined into a single dataset in my code. Any assistance in dynamically generating different datasets would be greatly ...

What is the best way to load the route calculation dynamically?

I am struggling with calculating the Google Maps route dynamically. The console shows an error stating that 'calcularRuta' is not defined: Uncaught ReferenceError: calcularRuta is not defined at HTMLInputElement.onclick (index.html:1) Despi ...

Performing server-side code execution while Node.js is functioning

Currently, I am working on developing a messaging app similar to Slack as a practice project. One of the key features I want to include is allowing users to create their own unique messaging space. Each time a user creates a new messaging space, a unique k ...