Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A major issue is the way your IDing your elements. You have a variable <strong>c</strong> which is numeric, starting at 0, increases whenever a link is clicked, and then is set as the ID as one of your iframes. However, you are also setting numeric IDs to the created tabs. Eventually, these element IDs will overlap and you will have errors like these.</p> <p>At the very least, make your iframes have the ID of </p> <ul> <li>"frame_" + $(link).attr("rel")</li> <li>rather than the <strong>ct</strong> numeric variable you are using now (copy of <strong>c</strong>)</li> </ul> <p>so that an example ID may be "frame_2" for the button with <em>rel</em> attribute of 2. That way you won't have a button with <em>rel</em> attribute of 2 connected to some frame with a random numeric ID.</p> <p>Get rid of the <strong>c</strong> variable completely.</p> <p>Instead of this loop:</p> <pre><code>if(ct&gt;1) { for(i=ct-1;i&gt;0;i--){ alert(i); fr = document.getElementById (i); if (fr.style.display!='none') fr.style.display="none"; } } </code></pre> <p>use:</p> <pre><code>$("#content").children("div.dcontent").each(function() { var theFrame = $(this).find("li iframe"); if ($(theFrame).attr("id") != ("frame_" + $(link).attr("rel"))) { $(theFrame).css("display", "none"); } }); </code></pre> <p>That way you can easily link the <em>rel</em> attribute to the frame's ID, rather than an arbitrary numeric value from your <strong>c</strong> variable.</p> <p>You should use your <em>rel</em> attribute for everything, since you've given your links that. You could use use something like <em>data-buttonid</em> and use .data() to access it, but that's up to you.</p> <p>Then when you ID everything, use that number to pair everything together. i.e.</p> <ul> <li>Frame ID: "frame_" + $(link).attr("rel")</li> <li>Tab ID/Name: "tab_" + $(link).attr("rel")</li> <li>A Name: "tab_anchor_" + $(link).attr("rel")</li> </ul> <p>Testing with the code I provided resulted in it executing how you want.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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