0

so i have a code like this:

if ($var == null || 'NULL'){ echo "<h1>something</h1>"; echo "<div id='footer'><b>something</b><br/><br/><br/></div>"; echo "<b>something</b>";} else {} 

so, on my main page the value var == null and that's great because i want those linse to be displayed in that page, but if i have an iframe somewhere else and i want to set this variable to 1 like $var = 1 so it doesn't show in the iframe but instead will show on the main page because there the value is null, how can i do this?

4
  • 1
    You can't detect if your page is being shown in an iframe with PHP. Commented Sep 26, 2012 at 13:20
  • are you sure you want to if ($var == null || 'NULL'), not if (is_null($var) || $var === 'NULL') ? Commented Sep 26, 2012 at 13:21
  • YOu should change if ($var == null || 'NULL'){ to if (empty($var)){ Commented Sep 26, 2012 at 13:22
  • 1
    yes, it's not an issue that, i meant if (empty($var)){ but my question how to trigger it from the iframe with someJquery or something Commented Sep 26, 2012 at 13:23

1 Answer 1

4

You can't detect an iframe on the server-side, but you can pass an additional parameter to your script when embedding an iframe on your page:

<iframe src="script.php?iframe=1"></iframe> 

And then check for the value of $_GET['iframe'].

Sign up to request clarification or add additional context in comments.

1 Comment

But you will lose it when you navigate to another page in the iframe.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.