0

I am not sure if this is possible or not... I am trying to replace a specific part of a URL from my iframe with a string that is part of the mainframe's URL parameter.

i.e. I am trying to dynamically replace the iframe google sheets public URL ID to render the sheet associated with the mainframes parameter.

Mainframe URL: www.mysite.com?sfds654fsgfg6sfg54gfhghdf6

iframe src= "https://docs.google.com/spreadsheets/d/e/[google id to insert here dynamically from mainframe]/pubhtml?

Intended Final Result

iframe src= "https://docs.google.com/spreadsheets/d/e/sfds654fsgfg6sfg54gfhghdf6/pubhtml?

javascript is my limitation as well

Thanks,

1 Answers1

-1

I'll assume you have the id you want to use as a variable and you also have a place in your page where you want to place this iFrame.

var url_string = window.location.href;
var url = new URL(url_string);
var id= url.searchParams.get("id"); //Or whatever your url parameter is called.
var iFrameDestination = document.getElementbyId("#iframeDest");

var ifrm = document.createElement('iframe');
ifrm.setAttribute('src', 'https://docs.google.com/spreadsheets/d/e/'+id+'/pubhtml');
iFrameDestination.appendChild(ifrm);
ZektorH
  • 2,680
  • 1
  • 7
  • 20
  • Hi @zektorH I'm new to this and am having issues pulling this all together with something I am working on. Are you interested in guiding me on a screen share so I can shadow you? I am willing to invest financially as well – Magnor Maxi Nov 11 '19 at 21:13
  • @MagnorMaxi I updated the answer to be more detailed. – ZektorH Nov 12 '19 at 08:10