1

I have built a very simple website. And stackoverflow has helped me a lot already, thank you for that!

In my first attempt of building the website, I hide and show div’s. It can be found here: vossebeldfietsen.co.nf. This took a bit too much load time. I then used an Iframe for the content, so the website only loads what it needs to, when it needs to. This version can be found here: vossebeldfietsen.nl.

Now, on the click of a link, three things happen: a .html file is loaded into the iframe, the size of the iframe is altered through javascript and the correct navigation button lights up through javascript.

<a href="content/werkplaats.html" target="contentframe" onclick="resizewerkplaats(); CngClass(this);return">Werkplaats</a>

Resizewerkplaats resizes the iframe to a size specified in pixels. CngClass changes the class of this element, so it’s picture changes through .css. However, in this way, if the back button is clicked, the iframe size and the ‘active’ navigation button doesn’t change.

I have tried executing the javascript command from within the werkplaats.html file loaded into the iframe. In this way, the file werkplaats.html should resize it’s parent iframe and set the active button in the navigation onload. I have also tried executing the commands onload of iframe, letting the commands look up the correct size and 'active' button inside the iframe's content. I have found many different commands which could be executed from inside an iframe or which could use a variable from inside an iframe, but nothing seems to work in my particular case. Also, non of the solutions on the web to automatically adjust an iframe's size seem to work either.

  1. Is there a way to execute the two javascript commands (alter iframe height and set navigation button to active) from inside the iframe’s content (a .html file)?
  2. Or is there another way to solve the back-button problem in vossebeldfietsen.nl that I didn’t think of?

Or is there another way to solve the back-button problem in vossebeldfietsen.nl that I didn’t think of?

3
  • Why not load the html in with an an ajax call and load it into a div instead of an iframe? The div would then automatically expand around the content. Jan 26, 2014 at 14:04
  • I didn't manage to load different content into a div yet. It would solve halve of my problem, so I am looking into it again.
    – Joost
    Jan 26, 2014 at 14:18
  • It turned out I really had to few knowledge to do this yet. I had some help with this part. Thank you for helping though!
    – Joost
    Mar 7, 2014 at 9:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.