Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

iFrames - Open new page where contents depend on what user previously selected?


I have a HTML page that presents the user with a few choices of jokes (Adult, Knock Knock, Bar..)

If the user selects 'Adult', a new page opens called 'Jokes.html' - with 'Adult.html' as the iFrames ('iFrame') source. If they select 'Knock Knock' - the same page opens but with 'KnockKnock.html' as the iFrames source, and so on.

Is there a simple way to do this (as I am new to JS)? And one that works across different browsers.

Thanks in advance


  • 3
  • 3
1 Solution
ZvonkoSystems architectCommented:
Check this:

<select name="jokeType" onChange="window.frames.iFrame.location=this.value">
<option value="about:blank">-select-
<option value="adult.htm">Adult
<option value="KnockKnock.html">Knock Knock
<option value="bar.htm">Bar
<iframe name="iFrame" width="100%"></iframe>

xDamianAuthor Commented:
Thanks Zvokno - but the iFrame is in a different page.

So the user makes a choice on say, Index.html, and, depending on their answer, either 'Adult.html' will appear in the 'iFrame' on 'Jokes.html', or it could be 'Bar.html' in the 'iFrame'.
ZvonkoSystems architectCommented:
Something like this: http:Q_21426214.html
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

xDamianAuthor Commented:
Close - but not quite.

Index.html will have images that they click. On clicking the image, the page 'Choice.html' will open where 'Index.html' once was. And the source page to the iFrame in 'Choice'html' will be determined by the image they chose at Index.html.

I tried the example above but could not get it to work
ZvonkoSystems architectCommented:
What's the name of this game? "Guess what my page looks like"??? Hey dude, show you html source here and state on what input action you expect what behaviour. We are wizards here, but guessing your next wish can become boaring...
xDamianAuthor Commented:
Thanks Z: In the end, the easiest option was to have the new page load into the current iFrame - rather than open up a brand new page and iFrame. So the example you gave above works then.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now