I'm not sure I understand ....
Is this correct?
You have a page (page2.php) with an iframe in it. Depending on which link is clicked to get to page2.php, one of two (or more) 'sub' pages are loaded into the iframe.
If that's correct then ...
On page2.php you would have some php like:
if($showgif){
$href = 'temp.gif';
} else {
$href = 'someotherpage.htm';
}
Then, in the HTML:
<iframe ... href="<?=$href?>" ...>
So, the only thing left, is where the $showgif variable came from.
That would be decided by the href that links to page2.php.
So, if the link is <a ... href="page2.php" ...> then 'someotherpage.htm' would go into the iframe.
<a ... href="page2.php?showgif=1" ...> would put the gif in the iframe.
Hope that answers your question.
P.