How to get parent iframe id in javascript?

Member

by dedrick , in category: Javascript , 7 months ago

How to get parent iframe id in javascript?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by samara , 6 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.

Related Threads:

How to get parent form id using knockout.js?
How to get id of element in an iframe?
How to get the data-id value from iframe tag?
How to get coordinates of a link in iframe in javascript?
How to pass argument from iframe to parent?
How to pass a value from iframe to the parent?