Forum Moderators: coopster

Message Too Old, No Replies

determine iframe name

         

th1chsn

4:27 pm on Jan 6, 2008 (gmt 0)

10+ Year Member



Is there a way to figure out which page in the iframe is showing using php?

I have a sidebar navigation that links to a page in an iframe and under it I want to put something like:

echo "You're viewing " .$pagename;

Where $pagename is the name of the iframe. Is this even possible?

coopster

2:49 pm on Jan 7, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



If I understand you correctly you are going to probably have to rely on client-side programming like JavaScript because if the left-hand navigation is not being requested and redrawn on those requests, you won't be able to use PHP to update the information being rendered.

th1chsn

8:18 pm on Jan 7, 2008 (gmt 0)

10+ Year Member



That's what I thought. I found a javascript solution that's working out well.

PHP_Chimp

9:02 pm on Jan 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There may be a way to do it in php, it all depends on how the url is get up.

For example -


// url = example.com/iframe?page=important_page
echo "You are viewing: {$_GET['page']});

Or if your pages have url's that can also be used as the page name.
For example -

$url = example.com/something/important_page
$bits = explode('/', $url);
$length_bits = count($bits);
$final_bit = $bits[$length_bits-1];
echo "You are viewing: $final_bit"

That is also assuming you are reloading the contents of the iframe when you change the page. So lots of assumptions...

[edited by: PHP_Chimp at 9:03 pm (utc) on Jan. 7, 2008]