0

I have two pages sem_menu.html and sem_menu2.html with the same headers, when sem_menu2 is contained and inserted in an iframe I hide the header of it so only the header of the sem_menu is displayed.

What I want to do is create a function that if sem_menu2 is contained in an iframe having the hidden header must write me in the sem_menu header while if it is not contained in an iframe then it is opened as a normal page it must write in its own header then of sem_menu 2.

if (window.parent.frames.length > 0) {
        alert(sessionStorage.sem_applicazione);
    } else {
        alert('no!')
    }

For now I have only this, can someone help me?

  • Does this answer your question? [How to identify if a webpage is being loaded inside an iframe or directly into the browser window?](https://stackoverflow.com/questions/326069/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t) – Tom Feb 09 '22 at 09:24
  • No my question is more specific that if the page is contained in an iframe my function must write it on the header of the page that contains it. – Claudia Mentuccia Feb 09 '22 at 09:26
  • Welcome to Stack Overflow! Please take the [tour] if you haven't already (you get a badge!) and read through the [help], in particular [*How do I ask a good question?*](/help/how-to-ask) You don't seem to have any code attempting to do the thing with the header. Your best bet here is to do your research, [search](/help/searching) for related topics on SO and elsewhere, and give it a go. ***If*** you get stuck and can't get unstuck after doing more research and searching, post a [mre] showing your attempt and say specifically where you're stuck. People will be glad to help. – T.J. Crowder Feb 09 '22 at 09:32
  • If you can find the top window, then you should be able to select the header of the top window and then do whatever manipulation you need from there – Tom Feb 09 '22 at 09:38

0 Answers0