473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Detecting IFRAME Container

42
I have a page that can be accessed either directly or by an AJAX tabs interface (courtesy jQuery). If accessed directly, I want the page's banner to be visible. If indirectly, the banner needs to be not displayed ('display:none').

If AJAX and IFRAMEs weren't involved, a containing object would be a pretty easy thing to detect. Since I'm using jQuery, though, I'm having trouble.

Any suggestions? Thanks.
Aug 2 '08 #1
4 3673
Hello,

This should tell you if your page has loaded directly or indirectly: top == window
If the current window is on the top, it will be true. If the current window is an IFRAME, it will be false.

I think you shouldn't use JavaScript for this, but rather use jQuery or the IFRAME or whatever you're using to send an extra parameter to the page (through GET) and parse it on the server. If your page was accessed using "minimize=1" you should output it with "display:none", otherwise you shouldn't touch the display of that menu.

Regards,
Tom
Aug 2 '08 #2
rnd me
427 Expert 256MB
give the banner an id of banner, then
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. if(location.href != top.location.href){ document.getElementById("banner").style.display="none"
  3. </script>
  4.  
  5.  
Aug 4 '08 #3
spamguy
42
Hello,

This should tell you if your page has loaded directly or indirectly: top == window
If the current window is on the top, it will be true. If the current window is an IFRAME, it will be false.

I think you shouldn't use JavaScript for this, but rather use jQuery or the IFRAME or whatever you're using to send an extra parameter to the page (through GET) and parse it on the server. If your page was accessed using "minimize=1" you should output it with "display:none", otherwise you shouldn't touch the display of that menu.

Regards,
Tom
This is actually a very good idea. It just requires an extra minute of effort to get working in the CodeIgniter PHP framework. Something like this in the controller:

Expand|Select|Wrap|Line Numbers
  1. function myTabsPage($banner) // '1' as URL parameter automatically put in $banner
  2. {
  3.     $data['display'] = $banner == 1 ? 'none' : 'block';
  4.  
  5.     $this -> load -> view('myView', $data);
  6. }
  7.  
And then...

Expand|Select|Wrap|Line Numbers
  1. <div id="banner" style="display:<?= $display ?>">awsum banner go here, lolz</div>
  2.  
Thanks, I'll definitely consider this.
Aug 4 '08 #4
You have been helpful ... I needed this to know how to go about manipulating things on my code. Now I know ...

Many thanks

give the banner an id of banner, then
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. if(location.href != top.location.href){ document.getElementById("banner").style.display="none"
  3. </script>
  4.  
  5.  
Nov 21 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Halldór Ísak Gylfason | last post by:
In my application I have an iframe that is empty (and not visible) initially, however when a user presses a button a form is programmatically submitted and the target is set to the IFrame. I...
3
by: Catherine Lynn Smith | last post by:
I want to know the recommended way to handle scripting of/with containers such as an iframe. I have a page with border-navigation bars on the top/bottom/left/right and I want to use an iframe to...
9
by: Julia Briggs | last post by:
How do I construct a <iframe> or equivalent for FireFox/NS browsers, inside a screen centered <div> tag? Can it be done?
4
by: Richard St?en | last post by:
Hi! We are experiencing a problem with running an .aspx page inside an iframe. The .aspx page is loading perfectly the first time (on load), but when we try to interact/navigate within the .aspx...
3
by: Peter | last post by:
I have a webform on this form is a User Control and another webform in IFRAME On the User Control there is a save button. I want to click this button and somehow tell the webpage in IFRAME that...
1
by: Testing12340 | last post by:
Hello!, I have this well, little IE issue. I'm showing hiding div's (containing IFRAMES), however, for some reason in IE one of the iframe contents allow me to click them (the last one allows me...
19
by: derelicten | last post by:
hello , I have an issue positionating some pics I want to anchor to an existing table cell but I cant just place regular position on the cell because the background is fixed height and the set of...
1
by: draw | last post by:
I have one container page "container.htm" In this container I have multiple iframes "iframepage1.htm", "iframepage2.htm", etc. and one button firing a js script to submit. In every iframe page I...
2
by: mynameisyohann | last post by:
hi guys, I am trying to make some iframes fit into a div with variable width. The iframe must have a margin, and using a padding in the parent div element is not an option. Unfortunately, the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.