I need to get the page url of what the iframe on my pages are on, as we use the iframe to deal with ordering products. However, for the life of me I can't seem to get it to display the iframe's URL (display is a test, as it will auto-email when I see it works)
The code:
<button onClick="myFunction()">Test</button>
<script>
function myFunction() {
alert(document.getElementById("iFrame").documentWindow.location.href);
}
</script>
<iframe src="https://iframe.mydomain.co.uk" id="iFrame" width="98%" height="100%"></iframe>
This code is being used on https://products.mydomain.co.uk. The alert, as I said, is only there so I can just press the button to see it showing the new domain, so that I can do what is needed for the rest of it.
Any ideas?