dubesinhower Posted July 1, 2010 Share Posted July 1, 2010 i recently coded a site. my friend told me to change my javascript variables to some javascript div visibility changing function, so that the content can be indexed. is this the optimum thing to do? also, i'm not sure how exactly to implement the function.my site Link to comment Share on other sites More sharing options...
NurAzije Posted July 1, 2010 Share Posted July 1, 2010 do not use variables, instead use DIV width style display:none; for example: <div style="display:none;" id="computernetworking">I am currently going to school for Computer Networking Technology at MCC in Connecticut. I've always been fascinated with how computers are able to communicate with each other; whether it's over the Internet or over a Local Area Network.</div> This will be indexed but it will not be visible on the page. On the image you use onclick='document.getElementById('computernetworking').style.display='';' for showing it and onclick='document.getElementById('computernetworking').style.display='none';' for hiding it again. Combine all this togother and you have what you want. Link to comment Share on other sites More sharing options...
dubesinhower Posted July 1, 2010 Author Share Posted July 1, 2010 do not use variables, instead use DIV width style display:none; for example:<div style="display:none;" id="computernetworking">I am currently going to school for Computer Networking Technology at MCC in Connecticut. I've always been fascinated with how computers are able to communicate with each other; whether it's over the Internet or over a Local Area Network.</div> This will be indexed but it will not be visible on the page. On the image you use onclick='document.getElementById('computernetworking').style.display='';' for showing it and onclick='document.getElementById('computernetworking').style.display='none';' for hiding it again. Combine all this togother and you have what you want. interesting, thanks. i'll have to try it out. Link to comment Share on other sites More sharing options...
Ingolme Posted July 1, 2010 Share Posted July 1, 2010 To improve accessibility, I suggest not adding "display: none" to the CSS of the <div> element.You should use Javascript to hide all the div elements upon page loading. This means that if Javascript is disabled, all the content will still be visible to the user.Here's a simple example I made:http://dtfox-tests.totalh.com/page.html Link to comment Share on other sites More sharing options...
dubesinhower Posted July 2, 2010 Author Share Posted July 2, 2010 To improve accessibility, I suggest not adding "display: none" to the CSS of the <div> element.You should use Javascript to hide all the div elements upon page loading. This means that if Javascript is disabled, all the content will still be visible to the user.Here's a simple example I made:http://dtfox-tests.totalh.com/page.html okay, i understand. the bottom script sets "main" as the initial div to load, but as you press links, the top script sets all divs to none in the loop, then shows the one that you pass to the function using the link.edit: i've made the changes live. if you have a second to check them over, please do! Link to comment Share on other sites More sharing options...
dsonesuk Posted July 2, 2010 Share Posted July 2, 2010 you have two errorsreturn false; should be within function show() {...}and<script type="text/javascript">divs = document.getElementsByTagName("div");show("default"); </script>should be placed at the bottom, above the close body tag </body>, placing it inside the div, causes it to run before all the content is rendered completely. Link to comment Share on other sites More sharing options...
dubesinhower Posted July 3, 2010 Author Share Posted July 3, 2010 you have two errorsreturn false; should be within function show() {...}and<script type="text/javascript">divs = document.getElementsByTagName("div");show("default"); </script>should be placed at the bottom, above the close body tag </body>, placing it inside the div, causes it to run before all the content is rendered completely.thanks for the first error, but the bottom script isnt inside the div. its where you said it should be. Link to comment Share on other sites More sharing options...
dsonesuk Posted July 3, 2010 Share Posted July 3, 2010 something strange here, when you view source the javascript is outside div container, firebug shows it as inside div container? looking at the source it appears you have more open div tags '<div>' (13) compared to close div tags '</div>' (11). Link to comment Share on other sites More sharing options...
dubesinhower Posted July 5, 2010 Author Share Posted July 5, 2010 something strange here, when you view source the javascript is outside div container, firebug shows it as inside div container? looking at the source it appears you have more open div tags '<div>' (13) compared to close div tags '</div>' (11).i'll look now. thats strange, but i am just using notepad ++ which has no intellisense.edit: i used the w3schools validator to find some errors. i fixed a few, like missing divs, but the validator finds errors for correct javascript. is there a fix for this? Link to comment Share on other sites More sharing options...
dsonesuk Posted July 5, 2010 Share Posted July 5, 2010 you have to use comment tagging like below:<script type="text/javascript"><!--//javascript code here...//--></script> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.