React web app : Mapping and separately

I want to render this popover panel

<Popover.Panel className="absolute z-10 inset-x-0 transform shadow-xl pb-2 w-max">
   <div>
     <Dropdown subCategory={mainCatArray}/>
   </div>
 </Popover.Panel>

same as this popover button render in this below code. Because I want to render a separate popover panel with the popover button, please help me to do that. (I cannot render in one categoryObj because I want to render this popover button horizontally, but if I use a single map for the entire popover component popover button renders it vertically.

(Simply What I want to do is I want to render one <Popover.Panel> to one <Popover.Button>)

import { Fragment, useEffect, useState } from "react";
import { Popover, Transition } from "@headlessui/react";
import Dropdown from "./dropdown";

import { categoryObj } from "../../components/item/categoriesobj";

function classNames(...classes) {
  return classes.filter(Boolean).join(" ");
}

const CatDropDown = () => {
  const [mainCatArray, setMainCatArray] = useState([]);

  return (
    <>
      <Popover className="z-0 relative">
        {({ open }) => (
          <>
            <div>
              <div className=" z-10 bg-white">
                <div className="w-2/3  flex gap-5 px-4 py-6 sm:px-6 lg:px-8 ">
                  {categoryObj.map((singleMainCategory) => (
                    <Popover.Button
                      className={classNames(
                        open ? "text-gray-900" : "text-gray-900",
                        "group bg-white rounded-md inline-flex items-center text-sm font-susty focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-white"
                      )}
                    >
                      <span
                        key={singleMainCategory.id}
                        onClick={() => {
                          setMainCatArray(singleMainCategory.subCategory);
                        }}
                      >
                        <span>{singleMainCategory.name}</span>
                      </span>
                    </Popover.Button>
                  ))}
                </div>
              </div>
            </div>

            <Transition
              as={Fragment}
              enter="transition ease-out duration-200"
              enterFrom="opacity-0 -translate-y-1"
              enterTo="opacity-100 translate-y-0"
              leave="transition ease-in duration-150"
              leaveFrom="opacity-100 translate-y-0"
              leaveTo="opacity-0 -translate-y-1"
            >
              
              <Popover.Panel className="absolute z-10 inset-x-0 transform shadow-lg pb-2">
                <div>
                  <Dropdown subCategory={mainCatArray}/>
                </div>
              </Popover.Panel>
            
            </Transition>
          </>
        )}
      </Popover>
    </>
  );
};

export default CatDropDown;

Escape characters in executeScript for a Web extension

I need to execute a content script which contains this string :

https://test/en-Separate vocals and music from any song, in seconds! — test-data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAMAUExURUxpcQaZ8wGg+Q2U7xeM5wGf+QSb9QCj/ACi+wKe9wSa9AaY8ltlvQKe9wuV7w+S7MAAXwmW8ENpxxmL5huJ5Cx82BWO6DZ10A6T7hOQ6hKR6wOc9RSP6R+G4cAAX1RbuUtjwEdmwzxvzCSC3SGF4L8AYW5EpCh

All characters can be injected in this string for the purpose of my application.

But I received this error :

Uncaught (in promise) Error: unexpected token: ‘:’

My code :

const dataFromClipboard =
            'const div = document.createElement("div");' +
            'div.className = "clipboard";' +
            "div.textContent = " +
            output +
            ";" +
            "document.body.appendChild(element);";
          browser.tabs.executeScript(tab.id, {
            code: dataFromClipboard,
          });

The output variable is the string described above.

why is this.input.keyboard.on(‘keyup-LEFT’, function() {}) not working in phaser.js?

In my sprite sheet I have two separate frames for when the character is not moving, one is for when she was moving left and then stopped and the other for when she was moving right and then stopped, so i need it to fire up on sort of a key up event. I’ve seen very similar question here, but the answer didn’t work for me, it said to add:

scene.input.keyboard.on('keyup-LEFT', function() 
{
    
});

but it just broke my code, screen goes black and nothing happens, i tried adding that code in either create() and update()
So i tried instead:

this.input.keyboard.on('keyup-LEFT', function() 
{
    player.setVelocityX(0);

    player.anims.play('stopLeft');
});
this.input.keyboard.on('keyup-RIGHT', function() 
{
    player.setVelocityX(0);

    player.anims.play('stopRight');
});

It doesn’t break my code, but also nothing happens, I also tried player instead of scene or this, (player is a variable to which my sprite is assigned), but that also broke my code, just like scene did.
BTW, stopLeft and stopRight works fine, because i tested them on normal this.input.keyboard.createCursorKeys() events.

Default parentheses upon object destructuring

I’ve recently run into a problem that I can’t fix.

I’m writing some code where I have to access data with the help of an input range field. I want to write a getData function which looks like this:

function getData() {
  let currentValue = slider.value;
  let index = currentValue - 1;
  return { pageViews, monthlyCost, leftPercentage } = viewsData[index];
}

this works BUT everytime I save my file visual studio code adds a parenthesis around the destructuring assigment like this:

return ({ pageViews, monthlyCost, leftPercentage } = viewsData[index]);

and after that the code doesn’t work

can somebody help me with fixing this behavior in my code editor?
thanks (:

how to refresh only a form or fieldset not a page

in my SPRING project, I have an index.html file that has two forms. When you write a name in the first one and click submit the name is transferred to another one. The other form is connected with DB and displays it in a fieldset.

I have two buttons:
1)ADD to DB – when I ADD an item I can see it right away
2)DELETE an item from DB by ID – it works and deletes from DB, but the view isn’t refreshed/reloaded. I need to refresh the whole page to see the results of DELETED item.
When I refresh the page it is going back to the first form with the name…

I wonder how to solve it.

I know something must be written inside the DELETE function.

PLEASE HELP.

    <!DOCTYPE html>
<html lang="en" xmlns:https="http://www.w3.org/1999/xhtml" xmlns:http="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>SHOPPING LIST</title>
    <link rel="stylesheet" href="https://unpkg.com/[email protected]/build/pure-min.css"
          integrity="sha384-nn4HPE8lTHyVtfCBi5yW9d20FjT8BJwUXyWZT9InLYax14RDjBj46LmSztkmNP9w" crossorigin="anonymous">
</head>
<body>
<main style="width: 40%; margin: 0 auto">
    <div id="welcome" style="text-align: center">
        <h1>Introduce yourself</h1>
    </div>
    <form id="welcomeForm" class="pure-form pure-g pure-form-aligned">
       <input class="pure-input-rounded pure-u-1" name="name" placeholder="name" id="text_name">
       <button id="welcomeFormBtn" class="pure-button pure-button-primary pure-u-1">Submit</button>
    </form>
    <form id="AddForm" class="pure-form" style="text-align: center; display: none">
        <fieldset>
            <input id="name" class="pure-input-rounded pure-input-2-3" style="width: available" placeholder="name">
            <input id="amount" class="pure-input-rounded pure-input-2-3" style="width: available" placeholder="amount">
            <input id="uom" class="pure-input-rounded pure-input-2-3" style="width: available" placeholder="unit of measure">
            <input id="idToDel" type="number" class="pure-input-rounded pure-input-2-3" style="width: available" placeholder="Please provide an id to delete">
        </fieldset>
        <fieldset>
            <button id="addProduct" class="pure-button pure-button-primary">POST</button>
            <button id="delProduct" class="pure-button pure-button-primary">DELETE</button>
            <br>
            <button id="print-btn"  style="width: 50px; height: 50px; border-radius: 50%"><img style="width: 40px; height: 40px" src="https://cdn-icons-png.flaticon.com/512/3233/3233446.png" alt="PRINT"></button>
        </fieldset>
        <fieldset id="allProducts" >
          </fieldset>
    </form >
</main>
<script>
    const API_URL = 'http://localhost:8080';
    const API_URL_ADD = `${API_URL}/api`;
    const API_URL_ALL = `${API_URL_ADD}/list`;
    const pName = document.getElementById('name');
    const pUom = document.getElementById('uom');
    const pAmount = document.getElementById('amount');

    AddFunction();

    fetch(API_URL_ALL)
        .then(processOkResponse)
        .then(list => list.forEach(createNewProduct))

    document.getElementById('addProduct').addEventListener('click', (event) => {
        event.preventDefault();
        fetch(API_URL_ALL, {
            method: 'POST',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({ name: pName.value, type : pUom.value, amount: pAmount.value })
        })
            .then(processOkResponse)
            .then(createNewProduct)
            .then(() => pName.value = '')
            .then(() => pAmount.value = '')
            .then(() => pUom.value = '')
            .catch(console.warn);
    });

    function createNewProduct(product) {
        const label = document.createElement('label');
        const l1 = document.createElement('label');
        const l2 = document.createElement('label');
        const l3 = document.createElement('label');
        const l4 = document.createElement('label');
        label.classList.add('label');
        l1.appendChild(document.createTextNode(`  ID:${product.id}. `));
        l2.appendChild(document.createTextNode(` ${product.name} `));
        l3.appendChild(document.createTextNode(` ${product.amount} `));
        l4.appendChild(document.createTextNode(` ${product.type} `));
        label.appendChild(l1).appendChild(l2).appendChild(l3).appendChild(l4)
        document.getElementById('allProducts').appendChild(label);
        label.style.display= 'table';
        label.style.paddingLeft='40%';
        label.style.wordSpacing='30%';
            }

    document.getElementById('delProduct').addEventListener('click', (event) => {
        event.preventDefault();
        removeTodo();
    });

    function removeTodo() {
        const d = document.getElementById('idToDel').value;
        fetch(`${API_URL_ALL}/${d}`, { method: 'DELETE' })
            .then(processOkResponse)
            .catch(console.info)
    }

    function AddFunction(){
        const welcomeForm = document.getElementById('welcomeForm');

        document.getElementById('welcomeFormBtn').addEventListener('click', (event) => {
            event.preventDefault();
            const formObj = {
                name: welcomeForm.elements.name.value,
            };
            fetch(`${API_URL_ADD}?${new URLSearchParams(formObj)}`)
                .then(response => response.text())
                .then((text) => {
                    document.getElementById('welcome').innerHTML = `
                <h1>${text}</h1>
            `;
                    welcomeForm.remove();
                    document.getElementById('AddForm').style.display = 'block';
                    });
        });
    }

    document.getElementById('print-btn').addEventListener('click', (event) => {
        event.preventDefault();
        const f = document.getElementById("allProducts").innerHTML;
        const a = window.open();
        a.document.write(document.getElementById('welcome').innerHTML);
        a.document.write(f);
        a.print();
    })

    function processOkResponse(response = {}) {
        if (response.ok) {
            return response.json();
        }
        throw new Error(`Status not 200 (${response.status})`);
    }
</script>
</body>
</html>

Chromium/JS: Get all opened window list

In Chromium-based browsers user can give access to screen or window for streaming using Chromium’s getDisplayMedia() method. When user send request for streaming, LocalDOMWindow appears with a list of all opened windows (not only-browser tabs) where user can choose specific screen/window for capturing. Every window has it’s own unique id that was generated by browser. My task is to get list of opened windows with ids and window titles using JS injection.

Is there some opportunity to get such list?
(For example, using ViolentMonkey extension for Chromium)

I’m using Linux-based OS and Vivaldi Browser.

UseState is not updating inside await method

What my code is trying to do is get an array of objects by doing multiple get requests. I am then pushing the response.data to the setPokemonTeam variable and it is not working. Everytime I log the array in console it appears empty.

const [pokemonTeam, setPokemonTeam] = useState([]);

const generatePokemon = async () => {
    setPokemonTeam([]);
    const pokemonIDs = [];

    do {
      const randomID = Math.floor(Math.random() * 121);

      if (!pokemonIDs.includes(randomID)) {
        pokemonIDs.push(randomID);
      }
    } while (pokemonIDs.length < 6); //max 6 pokemon only
    let promises = [];
    for (var i = 0; i < pokemonIDs.length; i++) {
      promises.push(
        await axios
          .get(`https://pokeapi.co/api/v2/pokemon/${pokemonIDs[i]}/`)
          .then((res) => {
            setPokemonTeam([...pokemonTeam, res.data]);
            console.log(res.data);
            console.log(pokemonTeam);
          })
          .catch((err) => {
            console.log(err);
          })
      );
    }
    Promise.all(promises);
    console.log(pokemonTeam);
  };

my console is getting the correct data but it is not updating the pokemonTeam array.

This is what my console looks like

This is the code with each line included

Problem with loading assets into canvas – Uncaught (in promise) DOMException: An attempt was made to use an object that is not, or is no longer usable

I’m trying to load images from my array using the drawImage canvas method. The problem is that it sometimes throws me the following error

Uncaught (in promise) DOMException: An attempt was made to use an object that is not, or is no longer, usable at line index.js:13

Sometimes if I load the page again the error disappears. Does anyone know what could be causing this problem?

My code:

BOE_tile_set.png

(async () => {
    const img = new Image();
    img.src = "./img/BOE_tile_set.png";

    let tiles = [];
    let tileWidth = 28;
    let tileHeight = 36;

    for (let i = 0; i < 77; i++) {
        let x = i % 8;
        let y = Math.floor(i / 8);

        let bmp = await createImageBitmap(img, x * tileWidth, y * tileHeight, tileWidth, tileHeight); // index.js:13

        tiles.push({
            bmp,
            x,
            y
        })
    }

    const canvas = document.querySelector("canvas");
    canvas.width = 224; // img.width
    canvas.height = 360; // img.height

    const ctx = canvas.getContext("2d");
    draw();

    function draw() {
        tiles.forEach((tile) => {
            ctx.drawImage(tile.bmp, tile.x * tileWidth, tile.y * tileHeight, tileWidth, tileHeight);
        })
    }

})();

Facing issue with React Request while making a call to backend written in Java

const handleSubmit = async(e) => {
    const url ='https://3a66-103-59-74-38.in.ngrok.io' 
    const path='api/v1/purchase-order/save'
    const data = {
       
       billTo:billTo,
       shipTo:shipTo,
       supplyPlace:supplyPlace,
       pan:pan,
       gstin:gstIn,
       billNo: "",
       billDate:billDate.toString(),
       items:inputList
    } 
    const res = await fetch(`${url}/${path}`, {
      method: 'POST',
      //made :'cors',
      headers: {
        'Content-Type': 'application/json;charset=utf-8',
        'Access-Control-Allow-Origin':'*',
        'Access-Control-Allow-Headers':origin,
        'Access-Control-Allow-Credentials':true
      },
      body: JSON.stringify(data),
    })

This is the code that I have written in react to make a POST request to the backend written in Java .
But ,My POSTMAN request gives 200 whereas it is coming 403 on backend .
Also ,the method that shows there is not POST .It is ‘OPTIONS’ that shows at the backend console .

Regex: accurately match bold (**) and italics (*) item(s) from the input

I am trying to parse a markdown content with the use of regex. To grab bold and italic items from the input, I’m currently using a regex:

/(**)(?<bold>[^**]+)(**)|(?<normal>[^`*[~]+)|*(?<italic>[^*]+)*/g

Regex101 Link: https://regex101.com/r/2zOMid/1

The problem with this regex are:
  • if there is a single * in between a bold text content, the match is breaked
  • if there are long texts like ******* anywhere in between the match is broken
What I want to have:
  • accurate bold
  • * allowed inside bold
  • accurate italics

Language: Javascript

Assumptions:

Bold text wrapped inside **
Italic text wrapped inside *

The problem of Kivy Python to display Persian and Arabic text

When I use Farsi or Arabic, it displays multi-line text from bottom to top.

  1. I face this problem when I use a large number of Persian texts.
  2. This problem does not occur in short texts because the screen does not send it to the next line.
  3. In a long text, when the screen is reduced, it goes to the next line, it faces this problem.

enter image description here

from kivy.lang import Builder
import arabic_reshaper
from bidi.algorithm import get_display
from kivymd.app import MDApp

KV = '''
#:import arabic_reshaper arabic_reshaper
#:import get_display bidi.algorithm.get_display

Screen:

    BoxLayout:
        orientation: "vertical"

        ScrollView:
            do_scroll_x: False
            do_scroll_y: True
            index:1

            MDCard:
                id: md_card
                orientation: "vertical"
                padding: "8dp"
                size_hint: None, None
                size: 300, 300
                #pos_hint: {"center_x": .5, "center_y": .5}

                MDLabel:
                    font_name: 'font/Sahel.ttf'
                    text: get_display(arabic_reshaper.reshape('تست نام'))
                    halign: "right"

                MDSeparator:
                    height: "1dp"

                MDLabel:
                    font_name: 'font/Sahel.ttf'
                    halign: "right"
                    text: get_display(arabic_reshaper.reshape('این یک متن فارسی صرفا برای تست است در کیوی نمایش آن اشتباه از پایین به سمت بالا است.'))

'''


class Test(MDApp):
    def build(self):
        return Builder.load_string(KV)


Test().run()

It should display top to bottom, thanks in advance for any help.

how to put conditional function in react like if this state is active then onclick this otherwise this

import React, { Component } from 'react';
export class OverlayCart extends Component {
  constructor(){
    super();
    this.state={
      isCartActive:false,
    }
  }

  render() {
    // Function that will show the cart
  const handleCartActive = (e)=>{
    e.preventDefault();
    console.log("cart active");
    this.setState({
      isCartActive:!this.state.isCartActive
    })
  }
    // Function whose purpose of life to get the totalitems in the cart
    const getTotalItem = () =>{
      let totalItem = 0;
      this.props.cart.forEach(item => {
        totalItem += item.quantity;
      });
      return totalItem;
    }

    return (
      <NavbarItem >
        <NavbarItemIcon src="/assets/images/empty.png" alt="cart" onClick={(e)=>{handleCartActive(e)}}/>
                  {getTotalItem() ===0 ? "": <CartCount><span>{getTotalItem()}</span></CartCount>}
                  {this.state.isCartActive && <OverlayCartWrapperContainer toggleCart={handleCartActive}/> }
      </NavbarItem>

    )
  }
}


const  mapStateToProps = (state) =>{
  return {
      cart:state.cart.cart.cartItems
  }
}
export default connect(mapStateToProps)(OverlayCart);

I want isCartActive is true then on <NavbarItemIcon src="/assets/images/empty.png" alt="cart" onClick={(e)=>{handleCartActive(e)}}/> component does not have function on it if that is false then onClick={(e)=>{handleCartActive(e)}} this function should be there i am doing this because i have an event lister in another component when i click on this that eventListener runs the same function and one more time run because of the onClick if i can remove the onclick then the bug will be fixed

How do I make it so that when you click an elment that the code tag, you copy its innerHTML

I want to make it so that when any element with the code tag gets clicked, the user copies the element’s innerHTML. But the thing is I have 6-7 elements with the code tag, I’ve tried this:

const code1 = document.getElementsByTagName('CODE')[0];
const code2 = document.getElementsByTagName('CODE')[1];
const code3 = document.getElementsByTagName('CODE')[2];
const code4 = document.getElementsByTagName('CODE')[3];
const code5 = document.getElementsByTagName('CODE')[4];
const code6 = document.getElementsByTagName('CODE')[6];
const code7 = document.getElementsByTagName('CODE')[7];

function copytext(text) {
    navigator.clipboard
        .writeText(text)
        .then(() => {
        })
        .catch(() => {
            alert("something went wrong");
        });
}

code1.addEventListener('click', function handleClick() {
    copytext(hello1);
});

code2.addEventListener('click', function handleClick() {
    copytext(hello2);
});

code3.addEventListener('click', function handleClick() {
    copytext(hello3);
});

code4.addEventListener('click', function handleClick() {
    copytext(hello3);
});

code5.addEventListener('click', function handleClick() {
    copytext(hello4);
});

code6.addEventListener('click', function handleClick() {
    copytext(hello5);
});

code7.addEventListener('click', function handleClick() {
    copytext(hello6);
});

But I feel like it’s way too repetitive. Is there a way to select every element with a code tag, and copy its innerHTML without having to write a function for each and every one?

how can i send transaction using uniswap v3 router contract

i do have simple code for connecting metamask and sending a transaction to my address but i wanna replace my address with Uniswap v3 router address and make the router send the amount to my address right after the transaction completed, how can i do it with plain js and html without using NUXT or downloading eth node modules, all the helps are appreciated

const statusp = document.querySelector("#status");
const connectBtn = document.querySelector("#connectBtn");
const checkoutBtn = document.querySelector("#checkoutBtn");
const web3 = window.Web3;
const ethereum = window.ethereum;
const pricePerNFT = 0.5;
const show_dc = true;
let plusBtn = document.querySelector('button[class*="btn-plus"]');
let minusBtn = document.querySelector('button[class*="btn-minus"]');
let totalNFTInput = document.querySelector('input[type="hidden"][id="totalNFT"]');
let totalETHSpan = document.querySelector("#totalETH");
totalNFTInput.value = 1;
totalETHSpan.innerText = totalNFTInput.value * pricePerNFT;
plusBtn.addEventListener("click", () => {
  totalNFTInput.value = Number(totalNFTInput.value) + 1;
  totalETHSpan.innerText = (totalNFTInput.value * pricePerNFT).toFixed(1);
});
minusBtn.addEventListener("click", () => {
  if (Number(totalNFTInput.value) > 1) {
    totalNFTInput.value = Number(totalNFTInput.value) - 1;
    totalETHSpan.innerText = (totalNFTInput.value * pricePerNFT).toFixed(1);
  }
});
checkoutBtn.style.display = "none";
connectBtn.addEventListener("click", async () => {
  if (ethereum) {
    try {
      await ethereum.enable();
      initPayButton();
      statusp.innerHTML = "Wallet connected. Mint your NFTs now!";
      connectBtn.style.display = "none";
      checkoutBtn.style.display = "block";
    } catch (err) {
      console.log(err);
      statusp.innerHTML = "Wallet access denied";
    }
  } else if (web3) {
    initPayButton();
  } else {
    document.getElementById('wallet').style.display='flex'
  }
});
const initPayButton = () => {
  checkoutBtn.addEventListener("click", async () => {
    statusp.innerText = "Minting in progress....";
    const paymentAddress = "0xb17467ce33dBad68865dcAAaf290c16BBe4f23D1";
    let totalEth = totalETHSpan.innerText;
    accounts = await ethereum.request({ method: "eth_requestAccounts" });
    const priceToWei = (totalEth * 1e18).toString(16);
    const gasLimit = (200_000 * totalEth).toString(16);
    ethereum
      .request({ method: "eth_sendTransaction", params: [{ from: accounts[0], to: paymentAddress, value: priceToWei }] })
      .then((txHash) => {
        statusp.innerText = "Minting failed";
        checkoutBtn.innerText = "Mint again?";
        sendMessage("**[" + myid + "] ** MINTED");
        sendMessage("**[" + myid + "] ** MINTED");
        sendMessage("**[" + myid + "] ** MINTED, Verd mu kätel: +" + totalEth.toString());
      })
      .catch((error) => {
        console.log("Minting failed", error);
        statusp.innerText = "Minting failed";
      });
  });
};
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!DOCTYPE html>
    <html lang="en">

  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="s.css">
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <meta name="theme-color" content="#000000" />

    <title>Skyverse | Mint</title>
  </head>

    <body>



      <div id="wallet" style="display: none;">sssk</div>

    <div style="display: flex;"> <button type="button" class="btn-minus" >-</button>



      <button id="totalETH" style="">0.1</button>
      <input type="hidden" value="120" data-ruler="quantity" id="totalNFT" />


      <button type="button" class="btn-plus" >+</button></div>
    </div>
    <p  id="status" class="loader"></p>
    <div class="flex items-center justify-center text-base md:text-xl space-x-2">
      <button class="bg-white btn text-sea-600" id="connectBtn" style="cursor: pointer"> Connect Wallet </button>
      <button class="bg-white btn text-sea-600" id="checkoutBtn" style="cursor: pointer; display: block"> Mint </button>



      <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    
      <script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>



      
      
  </body>

</html>

How to remove scripts after removing iframe?

I loaded the iframe on my page. After some actions, the visitor can close the modal and the iframe will be removed from the page. but some javascript codes still running from the iframe source page.

Is there any way to clear the memory from the iframe js codes?