Skip to main content
Participating Frequently
November 5, 2018
Answered

Iframe static size

  • November 5, 2018
  • 3 replies
  • 1611 views

I don't quite know how to frame this and it may already be answered, if so just link to the answer. I am trying iframes for the first time. Basically most of the pages on my site have a menu at the bottom of the page that points to different pages on my site, and that menu needs to be the same across pages. I currently copy and paste the contents in the window to the next page etc. and that works fine. However I have dozens of pages and changing all of them when I change the contents of the menu is a real PITA. So I created a page with just the contents of the menu. I can create an iframe that shows that menu page without any problems. I made the frame size fit the contents of the menu page. However if it's smaller than the menu page it shows scrollbars. a size that makes one scroll across or down to see the entire contents. I don't want that to happen, and I need it to dynamically change the size to fit the contents of the menu page if that page size changes. I can play with the width and height so that it doesn't scroll, but I don't know how this would be shown in other browsers (it does work on Firefox and IE).

    This topic has been closed for replies.
    Correct answer Nancy OShea

    Iframes are an emphatic  NO .   Security and performance issues aside, iFrames are a last resort for when you absolutely can't do it any other way.

    Sever-side Includes are a resounding YES .

    Alt-Web Design & Publishing: Server-Side Includes with PHP

    Another option is to fetch content with AJAX (asynchronous JavaScript and XML).

    AJAX Introduction

    3 replies

    orerockonAuthor
    Participating Frequently
    November 6, 2018

    I'm really trying to hold my tongue but it seems like whenever I ask a simple question in this forum I get shot down because I'm "doing it wrong". Some people may want to think of that, I'm sure quite a few people seeking some simple help are also fed up with it. For some of this isn't a way of life, just a way to construct and maintain rudimentary websites.

    BenPleysier
    Community Expert
    Community Expert
    November 7, 2018

    orerockon , I am sorry that you feel that way.  Basically, what Nancy has said is correct, you should not be using an iframe for that purpose, server side includes are a much better and safer way to go.

    This is not attacking you, it is Nancy's way (and probably that of most advisers in this forum)  of helping you. Yes you can use iframes if you prefer that method, but be assured that, aside of the perceived security risks, the implementation will be a lot harder than using SSI.

    Birnou, who is an educator, was asking Nancy what proof she has regarding the security risks when using iframes so that he can arm himself when passing the information on to his students.

    Because I am of the belief that an iframe is no more of a risk than script or link, I playfully joined the conversation as the devil's advocate, not aimed at you, but at both Birnou and Nancy.

    So, for that, I apologise.

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    B i r n o u
    Legend
    November 7, 2018

    BenPleysier  a écrit

    Birnou, who is an educator, was asking Nancy what proof she has regarding the security risks when using iframes so that he can arm himself when passing the information on to his students.

    although I have nothing against being an educator... I don't consider myself a educator...

    my main professional activity is based either in the development of mobile applications (generally for intranets of assistance companies, in the medical and hospital environment, marine insurance...) or in company support in order to help them set up solutions to manage their data flow...

    and it's true that in this case, it can often be likened to training... hence universities have often asked me to intervene as a pro speaker in their amphitheatre... from here to there, video2brain and Adobe then asked me to present some axes of their catalogue and in particular on DW and the technologies that revolve around it.

    but I'm not an educator for that...

    anyway, quite often students (if we have to call them that way) generally know much more than I do... I just have my own experience to offer them.

    in the amphitheatre, there is a desk and bleachers, but that is coming from the old age... quickly you find yourself mixed up in sharing the same passion and debating it (a little like here)... the only difference is between those who live financially from this passion and the others.

    Nancy OShea
    Community Expert
    Community Expert
    November 5, 2018

    And one more option you might want to read about is Dreamweaver's  proprietary Templates (DWT files).  

    How to design web pages based on Dreamweaver templates

    Alt-Web Design & Publishing: Working With Dreamweaver Templates (.dwt files)

    Nancy O'Shea— Product User & Community Expert
    Jon Fritz
    Community Expert
    Community Expert
    November 5, 2018

    Don't use iframes, they're really not the right way to do this.

    Use some basic Server Side Includes instead, they're far easier and make a lot more sense.

    If you have PHP installed on your server (most do) you simply create a small file that holds just the html from your menu (the include file). No <html>, <body> or <head> tags, nothing extra, just the code for the menu. You then call for that file with a small include snippet and the server writes the code from the include file where you place the snippet.

    PHP Tutorial - Include File

    orerockonAuthor
    Participating Frequently
    November 5, 2018

    Unfortunately I am limited to what I have. A related question while I have your attention. Is there a way to "discover" the size of a page?

    orerockonAuthor
    Participating Frequently
    November 5, 2018

    Iforgot to say that it appears to work just fine.