@tressie.damore
To get the coordinates of a link inside an iframe using JavaScript, you can follow these steps:
- Get the iframe element using JavaScript:
1
|
var iframe = document.getElementById('yourIframeId');
|
- Get the content document of the iframe:
1
|
var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
|
- Get the link element inside the iframe:
1
|
var link = iframeDoc.getElementById('yourLinkId');
|
- Get the coordinates of the link element:
1
2
3
4
5
|
var linkRect = link.getBoundingClientRect();
var linkCoordinates = {
top: linkRect.top + window.pageYOffset,
left: linkRect.left + window.pageXOffset
};
|
Now, the linkCoordinates
object will contain the top and left coordinates of the link element inside the iframe.