View Full Version : How to Switch Content Script II (icon based) to collapse when page opens ?

10-10-2013, 02:48 PM

1) script page : http://www.dynamicdrive.com/dynamicindex17/switchcontent2.htm

2) my website page : http://infocreditimmobilier.com/les-investissements-immobiliers-locatifs-defiscalises/. Please note that all pages have the script installed, with only one tab.

3) Problem: The tab opens automatically when viewer arrives on the page.

4) What I can't figure out : how to set the tab to be closed when the viewer arrives on the page, obliging the viewer to click the icon in order to open it. Why: because of Google Pinguin 4.:(

Heres is the code that I have set in the single.php (wordpress):

<div class="eg-bar"><span id="faq1-title" class="iconspan"><img src="minus-icon.png" /></span>Question ?</div>
<div id="faq1" class="icongroup1">
<br />

<script type="text/javascript">

var faq=new switchicon("icongroup1", "div") //Limit scanning of switch contents to just "div" elements
faq.setHeader('<img src="http://infocreditimmobilier.com/wp-content/uploads/2013/03/minus.gif" />', '<img src="http://infocreditimmobilier.com/wp-content/uploads/2013/03/plus.gif" />') //set icon HTML
faq.collapsePrevious(true) //Allow only 1 content open at any time
faq.setPersist(true) //No persistence enabled
faq.defaultExpanded(0) //Set 1st content to be expanded by default


Massive thanks in advanced for your help.

10-10-2013, 03:17 PM
You've set the 1st content to be open with this line;

faq.defaultExpanded(0) //Set 1st content to be expanded by default
Remove that line (like in demo 2) and the content won't open

10-11-2013, 02:16 AM
It's amazing how solutions to unsolvable problems can be simple. :eek:

Thanks a lot for this tip, it's indeed working.