Something like this should work:
const changeClock = (clock) => {
const frame = document.getElementById("iframeclock");
const url = new URL(frame.src, location.href);
url.searchParams.set("clock", clock);
frame.src = url.toString();
};
URL API - Web APIs | MDN[
^]
Demo[
^]