Ways to Conceal HTML Element on Android Devices with Version 4.3 and Below

Is there a way to prevent an element from rendering on an HTML page specifically for Android 4.3 and older devices?

I have a problem with an absolute positioned element that overlaps the content on my website, making it unreadable. The elements are coded before the content, and everything works fine on all devices except for those running Android 4.3 and older versions.

I tried using a script to detect the operating system of the device, but it only identifies Android in general, not the specific versions I need to target.

You can find the site link here, and I'm referring to rotated background elements.

UPDATE: I made some progress by fixing the display issue on Android 4.2 for the second half of the content. However, I still can't figure out why the first two elements remain visible when they should be hidden as well.

This is the code snippet that worked for me (credit to the source here ):

var ua = navigator.userAgent.toLowerCase();
if(ua.indexOf("Android") >= 0) {
  var androidversion = parseFloat(ua.slice(ua.indexOf("Android")+8)); 
  if(androidversion < 4.4) {
    document.getElementById(rotate_section_1).style.display = 'none';
  }
}

Answer №1

The useragent string is being converted to lowercase before searching for "Android" with a capital A.

It seems illogical that the statement

navigator.userAgent.toLowerCase();
would ever include the exact string "Android"

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

Add a click function to an element in a grid when it is databound

In my TypeCtrl ES6 class angular controller, I am using a kendo datagrid directive with a template for grid config options. Within the grid template, I need to call a method from the TypeCtrl class when a span within the row is clicked. However, the functi ...

Having trouble activating the onclick event on a radio button

In my testing framework, I have implemented a keyword-based approach using Selenium 3.x and Java. One of the web elements I am working with is: <input id="radiobutton" name="webserviceBarFlg" onclick="setReadOnly(this)" class="foo-input-radio-margin fo ...

Explication of syntax not functioning

Following the instructions provided here but encountering issues, any assistance? <script type="text/javascript" src="sh/src/shCore.js"></script> <script type="text/javascript" src="sh/scripts/shBrushJScript.js"></script> <lin ...

javascript function.turnOff() - deactivate default printer

Our system is designed to use the javascript .print() function, which automatically brings up the print dialog with the default printer already selected. I am looking for a way to disable this default setting so that users are required to manually select a ...

Error encountered in a Node.js Express application: 'Error in Jade template (version 1.0+): The usage of duplicate key "id" is not permitted.'

Seeking guidance on the following issue: Within my Express app, I am providing numerous parameters to a Jade template, resulting in an error message that states: Duplicate key "id" is not allowed. (After reviewing, I have confirmed that there is no para ...

Retrieving the source of the currently displayed image within a carousel of images

Looking to retrieve the src of the active image in a carousel of images. Currently, my code is as follows: $(document).ready(function () { $("#myCarousel1").on('slide.bs.carousel', function () { var ele = $('.carousel ...

What is the process for NPM to execute a command that is not located in the path directory?

When I try to run the ava command from my project directory that contains AVA tests, I encounter an issue because it is not in my path. In my project, the npm test command is configured as ava tests/*.js --verbose, and mysteriously manages to execute the ...

How to navigate to a particular list item in an unordered list

Upon reviewing previous examples and my own source code, I am struggling to figure out how to access a specific <li><a>the value in this</a></li> based on a provided parameter. Mockup: <ul class="selectBox-dropdown-menu selec ...

Tips for enlarging the tree view when running protractor exams. Check out this code excerpt below:

I have a code snippet below that represents one item out of many, each distinguished by ng-reflect-index. I am trying to write a test case to expand these nodes individually using Protractor. However, I am facing an issue in expanding the node using Prot ...

The importance of clearing the browser cache before every production deployment

When deploying a new production in React JS, it is essential to clear the cache. ...

Unique Version: When utilizing custom window.FileReader methods, Angular zone execution is bypass

Upon transitioning an Ionic/Angular project from Cordova to Capacitor, I found it necessary to override the default window.FileReader in order to successfully execute the onload() method. Here is the approach I took (https://github.com/ionic-team/capacitor ...

Unable to load new page using Selenium and Chromedriver

Currently, I am in the process of learning how to utilize Selenium with Python. As a beginner exercise, I have been attempting to click a button on a webpage. Although I have been able to successfully locate the button and click on it, an unusual issue ari ...

Tips for excluding specific codes from running in BeforeAll for a specific Describe() block in Jasmine

Currently, I am in the process of writing a Jasmine unit test spec. The JS file contains several describe() blocks. Within the BeforeAll function, my objective is to execute a function only for the "A" and "C" Describe-Blocks. How can this be accomplished ...

Identifying the empty population of a hasMany property

I'm facing a challenge that seems simple, but I'm struggling to find the solution. Currently, I'm working with Emberjs 2.8. In my model, I have an async: true property set up like this: models/my-model.js import DS from 'ember-data& ...

Expanding the dimensions of $state.store.object within a vue.js application

As I delve into learning Vue.js, I've noticed that the application I'm currently developing fetches data from a database and then organizes it into a list before binding and displaying it on the page. Here's a snippet of the code where this ...

Ensuring the authenticity of user login credentials

I have a form in my HTML where the user needs to input their name and password. <html> <body> <form action="welcome.php" method="post"> Name: <input type="text" name="name"><br> Password: <input type="text" name="password ...

Implementing serverside pagination using Datatable in Javascript: Passing POST request body data

Attempting to incorporate ServerSide pagination using Datatable for AJAX POST request The Javascript Code snippet below showcases the issue faced when utilizing JSON.stringify for data field, causing the API not to be triggered. $('#tripboard_table&a ...

Focus on the objective in genymotion

Is there a way to specify the target on the Genymotion emulator, such as using Google APIs? https://i.sstatic.net/4uzIb.png ...

Establish an HttpOnly cookie using JavaScript

Is it possible to convert a non-HttpOnly cookie into an HttpOnly cookie using JavaScript? ...

Using TypeScript to replace a current data type

Looking for a solution to implement a wrapper above the $http service in an AngularJS project. The goal is to have request promises with an abort() method. Attempting to achieve this by creating the following function: function request(params:ng.IRequest ...