var iframe = document.getElementById('invoiceIFrame'); var search = window.location.search + '//'; var silent = search.indexOf('silent') > 0; var parts = search.replace('?silent=true', '').split('/'); iframe.src = 'https://app.invoiceninja.com/' + parts[1] + '/' + parts[0].substring(1, 33) + '/' + parts[2] + (silent ? '?silent=true' : '');