Prevent OpenEMR from breaking out of iframe

For our implementation of OpenEMR we need to embed it in the Boonex Dolphin CMS system by means of an iframe.
The problem is that when you enter login details and click Enter, the program “breaks out” of the iframe and displays full-page in the browser, replacing our web site.
Preventing this by iframe settings such as sandboxing also disables the login and was no solution.
I then went through the code and found 3 files where window.top.location.href… is used and tried changing that to window.location.href
To no avail, OpenEMR continues to break out of the iframe.
I would appreciate it if you could tell me what and where to tweak to stop it from “going for the top” so we can use it embedded on our site.

OK, I found the solution. If anyone ever needs this, here’s the way to do it.
It is not the files with the top.location code that I mentioned in my post.
It is 3 other files, where one has to change target="_top" to target="_self".
The files are:
/interface/login/login.php
/interface/main/main_screen.php
/interface/main/main_title.php

Your suggestions and insights have been immensely helpful in resolving the initial issue of breaking out of the iframe by modifying the “target” attribute from “_top” to “_self” for the mentioned files.

However, after implementing this solution, I encountered a new challenge. Despite successfully preventing the breakout from the iframe, I now encounter the “Site ID missing in the session data” error within the embedded OpenEMR instance.

I’ve noticed that the last file mentioned, “/interface/main/main_title.php,” doesn’t contain any <form> tag within it. Upon further investigation, I discovered a <a> tag in this file with a “target” attribute set to “_top”. Consequently, I adjusted this attribute to “_self” as well in an attempt to ensure consistency across the modification.

Despite these adjustments, the “Site ID missing in the session data” error persists within the embedded OpenEMR instance.

I would greatly appreciate any further guidance or insights on how to address this new error while maintaining OpenEMR embedded within the iframe without disruption.
Attaching the screenshots for ref: