How to get parent iframe id in javascript?

Member

by dedrick , in category: Javascript , 3 months ago

How to get parent iframe id in javascript?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by samara , 2 months ago

@dedrick 

You can get the parent iframe id in JavaScript by accessing the parent property of the window object and then accessing the id property of the iframe element. Here is an example:

1
2
var parentIframeId = window.parent.frameElement.id;
console.log(parentIframeId);


This code will get the id of the parent iframe of the current window and log it to the console.