Switch Between Multiple p5.js Sketches in Single Webpage

Assuming you have a variable iframe which points to the HTMLIFrameElement of the running sketch you wanna pause, you can call: iframe.contentWindow.noLoop();

Alternatively, the window property of each HTMLIFrameElement is stored in the frames[] pseudo-array:

Let’s say you wanna pause the sketch running at the 3rd created HTMLIFrameElement, you simply call: frames[2].noLoop();

2 Likes