Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Douglas on December 30, 2019, 10:14:33 AM

Title: [HOW TO] When SMF is running in an iframe, change the parent's <title> text
Post by: Douglas on December 30, 2019, 10:14:33 AM
Question: How do I change the parent's page title text (inside <title></title) when running SMF in an iframe?
Original Topic:

(Note: This wasn't an issue that was posted, however, it was something I needed to have solved, in order for our site visitors to be kept happy).

(Note 2: You should really do this off a CHILD theme, so that your changes are not overwritten any time there is an update to SMF's core themes).

Open [YOUR SMF THEME DIRECTORY]/index.template.php
Code: [Select]
<title>', $context['page_title'], '</title>';
For SMF 1.x and 2.0.x,  add BEFORE:
Code: [Select]
<script src="" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script>parent.document.getElementsByTagName("TITLE")[0].innerHTML= "', $context['page_title'], '";</script>

(Note 3: For SMF 1.x and 2.0.x, get the current (latest) jQuery CDN code from

For SMF 2.1.x,  add BEFORE:
Code: [Select]
<script>parent.document.getElementsByTagName("TITLE")[0].innerHTML= "', $context['page_title'], '";</script>

This should work on ALL page types that have an iframed SMF... even WordPress (testing of this was done on a WordPress page with SMF 1.x running inside an iFrame)