1. PROMO Subscribe our All Access Pass @ 75% OFF & access all our 16+ premium Divi extensions: Divi Block Pro, Carousel Toolkit, etc.LEARN MORE
Dismiss Notice
NEW Divi.Help Pro Carousel AI Toolkit - Magically turn your Divi design into carousel, simply by using our online toolkit. No plugins needed. Now it works with Divi 5 as well!Try our carousel AI toolkit
BEST Divi Block - A revolutionary drag & drop tool to easily mix & match 960+ premade blocks (Light & Dark) to kick start your Divi site design. Special module designs are included as well. Also newly added AI generator & color. Now it works with Divi 5 as well!
Learn More About Divi BlockFree Version ~ 340+ Free Blocks

Solved 2 code blocks (with JavaScript) on 1 page?

Discussion in 'Free Divi Community Forum' started by Atmoz, Oct 13, 2023.

  1. Atmoz

    Atmoz New Member

    Dear all,

    I need 2 code-blocks on my page in order to seperate large chunks of JavaScript code. One block is for JS code for phone/tabled and the other for PC.

    The problem is that in both code-blocks I have a "run on page load function". And unfortunately, both these functions are fired when on phone and on PC. But what I need is that only the code-block for phone is active when browsing on phone, and when browsing on PC, the corresponding block is active.

    To test I put alert("on pc"); in the PC-block and alert("on phone"); in the phone-block, but both messages show up on both devices.

    After hours and hours of testing (including help from ChatGPT) I still can't get this working... Anyone knows if this is even possible?

    Many thanks in advance,

    Atmoz
     
    1. PRO MEMBER PERKS Beautifully crafted custom colored 'Freelancer' Divi layout for all Pro members:View Demo
  2. Atmoz

    Atmoz New Member