The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Link to a page, focus and display text
Jomathr
post May 1 2012, 04:25 PM
Post #1





Group: Members
Posts: 5
Joined: 1-May 12
Member No.: 17,021



Good day to all of you,

I am trying to link to another page, move that freshly loaded page to a specified position and display some hidden text from a link. I have been looking for something like this for a few days now with no success.

I'll try to explain a bit better with code first:

here is what I have so far on the first page where the link is
CODE

<li><img src="http://gatesinnovation.com/GATES/Images/icon1.gif"><p>Quel antivirus choisir?</p><a href="Conseils.html#conseil1" onload="document.getElementById('Conseil1').style.display = ''" <b>Plus</b></a></li>


It does part of what I want to do, it does send me to the other page and focus on the part intented, but as the text is hidden by default it is not showing and I can't display a default one since it might not always be the same text that is displayed.

The last part of this line of code is not working, from "onload" and forward.

here is the part in the target page that controls the text view/hide depending on what I click on that page:
CODE

<li><a href="#conseil1" onclick="document.getElementById('Conseil1').style.display = '';
                                    document.getElementById('Conseil2').style.display = 'none';
                                    document.getElementById('Conseil3').style.display = 'none';
                                    document.getElementById('Conseil4').style.display = 'none'";>Quel antivirus choisir?</a></li>
                                <li><a href="#Conseil2" onclick="document.getElementById('Conseil1').style.display = 'none';
                                    document.getElementById('Conseil2').style.display = '';
                                    document.getElementById('Conseil3').style.display = 'none';
                                    document.getElementById('Conseil4').style.display = 'none'">La copie de sauvegarde?</a></li>
                                <li><a href="#Conseil3" onclick="document.getElementById('Conseil1').style.display = 'none';
                                    document.getElementById('Conseil2').style.display = 'none';
                                    document.getElementById('Conseil3').style.display = '';
                                    document.getElementById('Conseil4').style.display = 'none'">Quel est l'utilité de...</a></li>                                
                                <li><a href="#">Support au bureau</a></li>


Anyone can help me with this? here are the 2 pages
Page with links Gates Innovation - first page
and here is the target page Gates Innovation - Target page

Thank you in advance

Jomathr
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
Christian J
post May 3 2012, 09:17 AM
Post #2


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



The type error doesn't occur anymore, now that you use window.location.href (instead of window.location) and quote the case values in the Switch statement. That way there seems to be no need for valueOf (at least not in the browsers I tested with), and in fact you're not even using it in the code example. unsure.gif

There's no function call to the FuncShow() function.

Using style.display = '' does not seem to undo an existing CSS "display: none". Try using a value like style.display = 'block' instead.

If DIVs are hidden with CSS but require JS to be shown, it will not work for users without JS. It's more reliable to use JS both for hiding and showing.
User is online!PM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 25th April 2024 - 09:48 AM