Computer Hope

Internet & Networking => Web design => Topic started by: Tomwatts on January 19, 2017, 04:48:04 AM

Title: HTML - Open link and display specific content in the next frame
Post by: Tomwatts on January 19, 2017, 04:48:04 AM
Hello,

I have a small website where I am writing articles, i have the below code on page 1:

<a href="./articles.php">Article Number One[/url]
<a href="./articles.php">Article Number Two[/url]

I would like both links to open the specific article in the page entitled article which has the below code:

<iframe src="./articles/article_viewer" frameborder="0" width="75%" height="100%" name="articles_viewert"></iframe>

How can i get it so when i click on Article 2 on page 1 it loads up the Article page then opens the article in the frame?

Thanks,
Title: Re: HTML - Open link and display specific content in the next frame
Post by: DaveLembke on January 19, 2017, 05:51:02 AM
Did you write the php code or are you using php that is generated elsewhere?

Dynamic HTML is the direction I feel your trying to go with this and running into your problems, so curious what your php code is doing if able to share the php here?
Quote
<a href="./articles.php">Article Number One[/url]
<a href="./articles.php">Article Number Two[/url]

articles.php is hyperlinked as the same php code for Article 1 and 2, so curious what your php code is to differentiate a user clicking on Article 1 vs 2. The way I see this you get the same result from clicking either link, so knowing what your php code is doing is needed for us to help further.

Quote
<iframe src="./articles/article_viewer" frameborder="0" width="75%" height="100%" name="articles_viewert"></iframe>

Knowing what your php is doing we can better assist with this. There is a lot of dynamic HTML that is going on with your php or should be going on in your php to display what you want.
Title: Re: HTML - Open link and display specific content in the next frame
Post by: Tomwatts on January 19, 2017, 06:37:18 AM
Hi thanks for the reply

Ignore the fact that they're PHP pages, they're currently empty and could be HTML pages, i'm not too concerned about that.

Just to clarify, what i'm aiming to do is this:

1. I have a page called Home which contains links to my articles, lets say:
       Article 1
       Article 2

2. When I click on one of the articles (lets say Article 2) it directs me to a new page called "Articles" and opens up the code in a <iframe> on that page called article_content.html.

Thanks,
Title: Re: HTML - Open link and display specific content in the next frame
Post by: camerongray on January 19, 2017, 09:31:56 AM
You would need to have some sort of URL parameter so the link to article one would be along the lines of "articles.php?article=article-one" then have something in article.php that reads this parameter and loads the correct article into the iFrame.

It would be helpful if you explained what the actual project is in more detail and why an iFrame is required.  Using iFrames in this way is seen as very outdated and is generally classed as bad practice.  Iframes should only be used when there is a good reason to (e.g. including a piece of content from another website such as when embedding a video), they shouldn't be used as general page layout elements or anything like that.