PDA

View Full Version : Resolved Reload iframe on select tab



Luys
08-10-2011, 06:01 PM
Hi all!

Yesterday I noted in these pages an issue which I will summarize below:

I made a "mother" page with three tabs, each of which contains an iframe with the respective "child" page.

I need to update the iframe of the second tab when this second tab is selected (at least only once), because being a "hidden" content when the whole page loads, there are items that fail to be drawn.

So, by trial and error (I have no knowledge of javascript) I have come to the point where I'm apparently about to achieve my goal. However, I need a little help and some advice.


1) This is my code:




<ul class="tabs" style="position:relative;top:-100px;margin-top:0px">
<li><a class="main" href="#">First tab</a></li>
<li><a class="" href="#" onClick="javascript:setTimeout(function() {window.location.href = 'iframefile.htm';}, 1000);return false;">Second tab</a></li>
<li><a class="" href="#">Third tab</a></li>
</ul>


I added the onClick sentence above, and the behavior is as expected: the tab is showed with all the content "visible" and then redirect to the "iframe file". Next I try first to insert a variation of target="_blank" to be sure of the internal mechanism of the code and also a "target="whatever" with the name of this second iframe.

My question is: Wich is the correct way to insert the "target + name of iframe" element in this formula? Is there anything wrong in its conception or as written?


2) At the head of the three "child" pages I have also the following code which means that if someone comes to any of these pages without going through the main page, it loads immediately. It works like a charm!



<script language='javascript'>try { if (top == self) {top.location.href='index.html'; } } catch(er) { } </script>


Is this code compatible with the structure of all pages? The behavior I want is that if a "child" page is loaded within the "mother" page this code has no effect at all, ie, do nothing. Or does need some modification?

Thanks in advance for your replies.

Luys

Luys
08-11-2011, 05:23 PM
This is my code


<ul class="tabs" style="position:relative;top:-100px;margin-top:0px">
<li><a class="main" href="#">First tab</a></li>
<li><a class="" href="#" onClick="javascript:setTimeout(function() {iframename.location.href = 'iframefile.htm';}, 1000);return false;">Second tab</a></li>
<li><a class="" href="#">Third tab</a></li>
</ul>


--------------

iframe name = "whatever"


As a famous magician, I impose myself a medal... ;-)