scroll on ios in mobile version

I have a scroll problem only on ios in mobile version.
Sometimes I get stuck on the top of my page if I scroll fast.
If you test this page on iphone http://www.espace-piano.ch/ESPACE_PIANO_WEB/FR/cours.awp you will sometimes have the same problem as I have. The problem is often after the page refresh.
If I switch to “computer version” on safari on my iphone, I no longer have a problem.

Is it possible in javascript to force the browser to “computer version”.

I already have this code to know if the user is on iphone…, I just miss the code to force in “computer version” on the browser.

let isIOS = /iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === ‘MacIntel’ && navigator.maxTouchPoints > 1);

I’m calling js in function file but it’s not working

Hi I’m trying to call javascript in WordPress function file but it seems it’s not working

<?php

function com_web() {
    wp_enqueue_script('main-cw-js', get_theme_file_uri('/build/index.js'), array('jquery'), '1.0', true);
    wp_enqueue_style('google-fonts', '//fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700,700i|Roboto:100,300,400,400i,700,700i');
    wp_enqueue_script('font-awesome', 'https://kit.fontawesome.com/bd6f15565d.js');
    wp_enqueue_style('com_main_styles', get_theme_file_uri('/build/style-index.css'));
    wp_enqueue_style('com_extra_styles', get_theme_file_uri('/build/index.css'));
}
add_action('wp_enqueue_scripts', 'com_web');

Compare 2 elements

Below is a typical way to check if the focus is on an element certain (txtCmd),

if(document.activeElement === txtCmd){
                return
}

I’m worried the operator=== would compare the entire element tree (every attribute and every sub-element) that would be low performance.

Does just compare the elements’ Ids is better?

document.activeElement.id === txtCmd.id

PS: There are no different elements with identical ID in the page.

How to save an array that can be used all over the repository like a db?

I am creating a WhatsApp bot and I am gonna create a feature that disables commands.

So I want to save/export an array of elements without losing any data.

function disableCommand(cmd) {
 const disabledCommands = [];
 disabledCommands.push(cmd);
}

I know to create a function like above but I actually don’t want to create a function, instead I wanna push command in disabledCommands array which can be used by exporting or some other way that can be used all over the repository ( Like a db ).

QUESTION CODE TYPE – NODEJS

Can anyone help?

Why elements move to the left once a draggable element’s been dropped into a valid target?

I’ve written an “if statement” in “drop()” so that when the condition is met the user can drop the draggable element into a valid droppable element. The issue I’m running into is that once it’s done all the elements are moved to the left. What I’d like is for the droppable elements to stay in place. But I haven’t the foggiest how to go about it. Help please.

const questionQuiz = document.querySelector(".question");
const answerchoices = document.querySelector(".answerchoices");
const allChoices = Array.from(document.querySelector(".answerchoices").children)
const choiceA = document.querySelector(".choiceA");
const choiceB = document.querySelector(".choiceB");
const choiceC = document.querySelector(".choiceC");
const start = document.querySelector(".start");
const quizSection = document.querySelector(".quizSection");
const choices = document.querySelectorAll(".choice");


let activeQuestion = 0;
let dragged;




let questions = [

  {
    question: "How many Grand Slam men's singles titles has he won?",
    choiceA: 10,
    choiceB: 15,
    choiceC: 20,
    questionImg: "url(images/federer.jpeg)",
    correctAnswer: 20,
  },

  {
    question: "How many Formula One World Championship has he won?",
    choiceA: 5,
    choiceB: 7,
    choiceC: 10,
    questionImg: "url(images/hamilton.jpeg)",
    correctAnswer: 7,
  },

  {
    question: "How many NBA title has Lebron won?",
    choiceA: 6,
    choiceB: 3,
    choiceC: 4,
    questionImg: "url(images/LeBron.png)",
    correctAnswer: 4,
  },

  {
    question: "How many Ballon D'or has the Argentinina won?",
    choiceA: 5,
    choiceB: 6,
    choiceC: 7,
    questionImg: "url(images/LeBron.png)",
    correctAnswer: 7,
  },

]
//
function renderQuestion() {
  let q = questions[activeQuestion]
  choiceA.innerHTML = q.choiceA;
  choiceB.innerHTML = q.choiceB;
  choiceC.innerHTML = q.choiceC;
  questionQuiz.innerHTML = q.question;
  // document.body.style.backgroundImage = q.questionImg
}

renderQuestion()

questionQuiz.addEventListener("drag", function(e) {

})

questionQuiz.addEventListener("dragstart", function(e) {
  console.log("start");
  dragged = e.target;
  console.log(dragged.innerHTML)
});

questionQuiz.addEventListener("dragend", function() {
  console.log('end')
});

allChoices.forEach((choice) => {
  choice.addEventListener("dragover", dragOver)
});

allChoices.forEach(choice => {
  choice.addEventListener("dragenter", dragEnter)
});

allChoices.forEach(choice => {
  choice.addEventListener("dragleave", dragLeave)
});

allChoices.forEach(choice => {
  choice.addEventListener("drop", drop)
})


function dragOver(e) {
  e.preventDefault()
  console.log("dragover")
}

function dragEnter(e) {
  e.preventDefault();
  console.log("dragenter");
}

function dragLeave() {
  console.log("dragleave")
}

function drop(e) {
  e.preventDefault()
  if(parseInt(e.target.innerHTML) !== questions[activeQuestion].correctAnswer) return;
  e.target.appendChild(dragged)
}
body {
  background-repeat: no-repeat;: 
}


.quizSection {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.question,
.answerchoices > *{
  height: 100px;
  width: 100px;
  border: 1px black solid;
}

.answerchoices > *{
  margin-bottom: 15px;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="index.css">
    <title>Drag And Drop</title>
  </head>
  <body>

    <div class="quizSection">
      <div class="question" draggable="true"></div>
      <div class=answerchoices>
        <div class="choiceA">choiceA</div>
        <div class="choiceB">choiceB</div>
        <div class="choiceC">choiceC</div>
      </div>

      <div class="start">Start quizz</div>
    </div>


    <script src="index.js" type="text/javascript"></script>

  </body>
</html>

How to set up the interaction of multiple sliders swiper js

I have 4 sliders on my website that are interconnected, and when switching one slider, all the others should switch, I implemented this using controller.control, but the problem is that on 2 sliders I have SliderPerView:3, and on the other two by SliderPerView:1, and that is, the last 2 switch not to their full slide, but to 1/3. Maybe someone has encountered this and knows how to solve it, I will be very grateful?

Dynamic object name javascript [duplicate]

I have two object with same method

const obj1 = {
    log: () => {
        console.log('Call function')
    }
}
const obj2 = {
    log: () => {
        console.log('Call function')
    }
}

I want to call this method but with the name of the dynamic object. I have try this but that d’ont work :

let dynamiqueName = "obj1"
dynamiqueName.log()

[dynamiqueName].log()

Getting an error trying to run rapidapi call using async and await

I keep getting the following error when I try to run a GET request from Rapid API

Uncaught (in promise) ReferenceError: Cannot access 'getData' before initialization

const RAPIDAPI_KEY =
  import.meta.env.VITE_RAPIDAPI_KEY;
const GEOLOCATION_URL = "https://ip-geo-location.p.rapidapi.com/ip/check?format=json";
const GEOLOCATION_HOST = "ip-geo-location.p.rapidapi.com";

const getData = async(url, host) => {
  const response = await fetch(url, {
    method: "GET",
    headers: {
      accept: "application/json",
      "x-rapidapi-host": host,
      "x-rapidapi-key": RAPIDAPI_KEY
    }
  })

  if (!response.ok) {
    throw new Error(`HTTP error! status: ${response.status}`)
  }

  return await response.json();
}

const runApiQueries = async() => {
  // GET CITY NAME
  const getData = await getData(GEOLOCATION_URL, GEOLOCATION_HOST);
  console.log(getData);
}

runApiQueries();

image slider with javascript with next previous button

The general appearance of the program is as follows:
enter image description here

the details
In this exercise, we complete a simple slider. You must add the previous and next button in this event. The next or previous image should be displayed when the next or previous button is clicked. You can use the functions defined in the initial project.

When the slider is on the last image and the next button is clicked, the first image should be displayed and also when the first image of the previous button is clicked, the last image should be displayed.

Note: When an image is displayed, its opacity must be 1 and the rest of the images must be 0.

Notes
You are only allowed to make changes to the main.js file.
html code :

const sliderImages = [
    "./images/image1.jpg",
    "./images/image2.jpg",
    "./images/image3.jpg",
    "./images/image4.jpg",
];
const sliderDom = document.getElementById("slider");

let currentImage = 0;

function renderImages() {
    sliderImages.forEach((image) => {
        sliderDom.innerHTML += "<img src='" + image + "' />";
    });
}

function clearImages() {
    const images = document.getElementsByTagName("img");
    for (let i = 0; i < images.length; i++) {
        images[i].style.opacity = 0;
    }
}

function showImage(image) {
    clearImages();
    document.getElementsByTagName("img")[image].style.opacity = 1;
}

function init() {
    renderImages();
    showImage(currentImage);
}

init();

let myBtn = document.querySelector("#prevButton");

myBtn.onclick = function() {
    const newImage = (currentImage + 1) % sliderImages.length;

    showImage(newImage);
}
let myBtn2 = document.querySelector("#nextButton");

myBtn2.onclick = function() {
    const newImage = (currentImage + 1) % sliderImages.length;
    showImage(newImage);


}
* {
  margin: 0;
  padding: 0;
}

button {
  padding: 8px;
}

.container {
  width: 500px;
  margin: 20px auto;
}

#slider {
  position: relative;
  height: 400px;
  margin-bottom: 20px;
}

#slider img {
  width: 500px;
  height: 400px;
  position: absolute;
  transition: all .5s;
}

.buttons {
  display: flex;
  justify-content: space-between;
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="style.css">
  <title>Slider</title>
</head>
<body>
  <div class="container">
    <div id="slider"></div>

    <div class="buttons">
      <button id="prevButton"><</button>
      <button id="nextButton">></button>
    </div>
  </div>
  
  <script src="main.js"></script>
</body>
</html>

a website that is blocked from being embedded in an iFrame. I need a legal workaround that allows me to post my store on my website

I need to add a website that is blocked from being embedded in an iframe. I need a legal workaround that allows me to post my store on my website. I’m not trying to hack anybody. Just want to safely and legally bypass this restriction. Thanks. 🙂
As it is not working kindly give me a solution or solve it and sent me the code will be appreciated thanks alot

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
  <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
  <META HTTP-EQUIV="Expires" CONTENT="-1">

  <html>

  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>NextierAffiliate.com</title>

    <style type="text/css">
      <!-- html {
        height: 100% !important;
        margin-bottom: 0px;
      }
      
      td img {
        display: block;
      }
      
      body {
        margin-top: 0px;
        margin-left: 0px;
        margin-right: 0px;
      }
      
      #apDiv1 {
        POSITION: fixed;
        WIDTH: 292px;
        BOTTOM: -22px;
        DISPLAY: block;
        HEIGHT: 222px;
        VISIBILITY: visible;
        RIGHT: 145px;
        padding: 0px;
      }
      
      -->
    </style>

    <script language="javascript">
      function DoClose() { <!-- Close the Popup
        document.getElementById('apDiv1').style.visibility = "hidden";
        return false;
      }
    </SCRIPT>

    <script type="text/javascript">
      <!--
      function MM_reloadPage(init) { //reloads the window if Nav4 resized
        if (init == true) with(navigator) {
          if ((appName == "Netscape") && (parseInt(appVersion) == 4)) {
            document.MM_pgW = innerWidth;
            document.MM_pgH = innerHeight;
            onresize = MM_reloadPage;
          }
        }
        else if (innerWidth != document.MM_pgW || innerHeight != document.MM_pgH) location.reload();
      }
      MM_reloadPage(true);
      //-->
    </script>



  </head>

  <body>

    <iframe id="iframe" src="<%= Session(" goURL ") %>" style="margin:0; width:100%; height: 100%; border:none; " cellpadding="0"></iframe>

    <div id="apDiv1">

      <table width="200" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><img src="<%= Session(" naPopupImage ") %>" width=4 00; height=1 93; alt="" usemap="#mfmLink" border="0" />
            <map name="mfmLink" id="mfmLink"><area shape="rect" coords="367,4,391,26" onmouseover=" this.style.cursor='pointer';" onclick= "DoClose()"  />
          <area shape="rect" coords="5,29,394,217" href="http://www.nextieraffiliate.com" target="_blank" />
      </map></td>
        </tr>
      </table>


  </body>

  </html>