Keep iframe content to display source html, but have source page to redirect -
i have iframe displays content html page (within same domain), let iframe content mydomain.com/page1.html.
obviously, want content of page1.html displayed within iframe.
however, have file (page1.html) redirected main site (mydomain.com) when whole url (mydomain.com/page1.html) typed in browser - without changing inside iframe.
is doable? appreciate help. thanks.
yes, wrote, sounds want happen:
mydomain.com/page1.html typed browser redirects mydomain.com/
mydomain.com/page1.html loaded iframe not redirect stays in iframe unchanged
you can add simple script page1.html accomplish this:
<script> if (top == self) location.href = '/'; </script> warning: not add script domain's default home page or else cause infinite loading loop.
self-contained example
home page index.html contains:
<p>this home page, containing frame.</p> <iframe src="page1.html"></iframe> frame page page1.html contains:
<script> if (top == self) location.href = '/'; </script> <p> page display in frame only. loading directly main page redirect user default home page of website. </p> result
loading website's main domain show text "this home page, containing frame." frame, containing "this page display in frame only...."
directly entering website's main domain followed /page1.html redirect main domain's home page itself.
Comments
Post a Comment