cip6791 Posted June 12, 2008 Share Posted June 12, 2008 Hello I need a little help with something. The following links display 3 different divs on one page <li id='textLinia' onclick="switchOptions('divLinia');" onmouseover="this.style.cursor = 'pointer';"><a href="#">Gama</a></li> <li id='textPiele' onclick="switchOptions('divPiele');" onmouseover="this.style.cursor = 'pointer';"><a href="#">Tip de piele</a></li> <li id='textTrat' onclick="switchOptions('divTrat');" onmouseover="this.style.cursor = 'pointer';"><a href="#">Tip de tratament</a></li> I would like to set links from other pages to this page, but I want the links to link to the page with certain divs showing. How can this be done? Thanks Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 12, 2008 Share Posted June 12, 2008 Try adding this in you HEAD tags: <script type="text/javascript"> window.onload = function ( ) { var matches = window.location.href.match(/#(.+?)$/); if(matches[1]){ switchOptions(matches[1]); } } </script> then, when you link to the page, specify the 'content' with the anchor tag: http://yourhost.com/path/to/page.html#divPiele Quote Link to comment Share on other sites More sharing options...
cip6791 Posted June 12, 2008 Author Share Posted June 12, 2008 cool ... thanks. it works ... but there is one thing that isn't quite right. when the page loads, the first div shows up for one second then the other div loads. can this be solved? maybe it s just on my end ... check it out http://pixeltennis.com/produse_cosmetice_roc.html# <--- page with the three divs http://pixeltennis.com/produse_html/sub_produse/roc_anti_cellulite.html <--- page with the links. thanks for your help Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 12, 2008 Share Posted June 12, 2008 there isn't really a way around that....you could have all three hidden at first, then add an else to the onload where if no page is specified, the first is shown. but, if someone doesn't have javascript enabled, your site wouldn't show any content. the other option is to do it with php...is php an option? Quote Link to comment Share on other sites More sharing options...
cip6791 Posted June 12, 2008 Author Share Posted June 12, 2008 hmmm .. how would i do it with the else option? Quote Link to comment Share on other sites More sharing options...
cip6791 Posted June 12, 2008 Author Share Posted June 12, 2008 http://it.roc.com/xhtmlbgdisplay.jhtml?itemname=retinoxplus_soin_jour&context=3&smi=1 the original page works fine. i just don't know javascript or php to create such an advanced site. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 12, 2008 Share Posted June 12, 2008 take that code I had you put in the HEAD out and add it after the DIVs, like so: <!--End gama !!! --> <div id='divPiele' style="display:none; margin:0; height:340px;"> <iframe frameborder="0" scrolling="no" src="produse_cosmetice_roc_piele.html" width="752" height="340"></iframe> </div> <div id='divTrat' style="display:none; margin:0; height:340px;"> <iframe frameborder="0" scrolling="no" src="produse_cosmetice_roc_tratament.html" width="752" height="340"></iframe> </div> <!-- Set the page --> <script type="text/javascript"> var matches = window.location.href.match(/#(.+?)$/); if(matches[1]) switchOptions(matches[1]); </script> Quote Link to comment Share on other sites More sharing options...
cip6791 Posted June 12, 2008 Author Share Posted June 12, 2008 works a lot better ... thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.