Home > Blockchain >  function navigate() { document.getElementById
function navigate() { document.getElementById

Time:03-04

I am having an issue trying to figure out how to add custom code to a URL that when clicked, it reloads an iframe on the page. I only have access to the URL.

iframe ID = gfgFrame

function navigate() { document.getElementById("gfgFrame").src = "/ClientCommunity/s/all-products?fileInfo=abcXyz";}

URL: javascript:navigate()

How can I add the above directly to the URL instead of using the javascript:navigate() ?

CodePudding user response:

If your iframe has a name attribute you can just make an anchor with target="theIframesName"

<a href="/ClientCommunity/s/all-products?fileInfo=abcXyz" target="gfgFrameName">click</a>

CodePudding user response:

The following code worked:

javascript:(() => {document.getElementById("gfgFrame").src="/ClientCommunity/s/product-results?fileInfo=xyz";})();

  • Related