Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamic creation of tab with iframe
    primarykey
    data
    text
    <p>I am creating tabs dynamically when an user clicks a menu. The referenced html file is opened within a iframe which is also created dynamically.</p> <p>Everything worked fine but When the tab count exceeds '<strong>3</strong>' and the user clicks on the previous tab the next iframe gets displayed below the previous iframe content.</p> <p>Below is the code i used. Can anyone suggest what should i do ? </p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt; &lt;html&gt;&lt;head&gt; &lt;script text/javascript&gt; $(document).ready(function() { var c=0; $("#documents a").click(function() { c++; addTab($(this),c); return false; }); $('#tab1 a.tab').live('click', function() { // Get the tab name i = 0; var chk; var contentname = $(this).attr("id") + "_content"; var ifid=$("#content .dcontent:last iframe").attr("id"); // hide all other tabs if(ifid&gt;1) { for(i=ifid;i&gt;0;i--) { fr = document.getElementById (i); if (fr.style.display!='none') { fr.style.display="none"; } } } //make the current frame visible var lnm=$(this).attr("name"); fr = document.getElementById (lnm); if (fr.style.display=='none') fr.style.display="block"; $("#tab1 li").removeClass("current"); // show current tab $(this).parent().addClass("current"); }); }); /* Creation of Tab*/ function addTab(link,ct) { // If tab already exist in the list, return if ($("#" + $(link).attr("rel")).length != 0) return; // hide other tabs $("#tab1 li").removeClass("current"); if(ct&gt;1) { for(i=ct-1;i&gt;0;i--){ fr = document.getElementById (i); if (fr.style.display!='none') fr.style.display="none"; } } // add new tab and related content $("#tab1").append("&lt;li class='current'&gt;&lt;a class='tab' id='" + $(link).attr("rel") + "' name='"+ct+"' href='" + $(link).attr("href") + "' target='" + $(link).attr("target") + "'&gt;" + $(link).html() + "&lt;/a&gt;&lt;a name ='"+ct+"' href='#' class='remove' &gt;x&lt;/a&gt;&lt;/li&gt;"); var e = $('&lt;div class="dcontent" &gt;&lt;li style="list-style:none;"&gt;&lt;iframe id="'+ct+'" src='+$(link).attr("href")+' name="content" align="middle" width=600px; height=400px;&gt; &lt;/iframe&gt;&lt;/li&gt;&lt;/div&gt;'); $('#content').append(e); } &lt;/head&gt; &lt;body&gt; &lt;ul id="tabs"&gt; &lt;!-- Tabs go here --&gt; &lt;div style="float: left;"&gt; &lt;ul id="menu"&gt; &lt;li&gt; &lt;a href="#"&gt;Next&lt;/a&gt; &lt;ul id="documents"&gt; &lt;li&gt;&lt;a href="tab1.html" target="content" rel="1" &gt;Document4&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="tab2.html" rel="2" target="content" &gt;Document5&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="tab3.html" rel="3" target="content" &gt;Document6&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="tab4.html" rel="4" target="content" &gt;Document6&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/ul&gt; &lt;ul id="tab1"&gt; &lt;div style="float: left;"&gt; &lt;/ul&gt; &lt;div id="content"&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload