how to provide "read more" link to a long article ?
actually i don't have any idea how it is done, so i post it here rather than in any specific section.
"Read More>>" link ?
Moderator: General Moderators
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
Re: "Read More>>" link ?
If you're talking about doing this on a blog, and you use blogger, I have found this method to be the most workable:
http://www.eblogtemplates.com/how-to-ad ... osts-link/
http://www.eblogtemplates.com/how-to-ad ... osts-link/
Re: "Read More>>" link ?
nope m not using it in any blog.
in new site..
in new site..
Re: "Read More>>" link ?
Well, to do it with JavaScript, anyway...
Add to the header:
Make sure you have CSS Classes for "Hide" which sets the display to "none" and one for "show". Personally, I have two; "showInline" and "showBlock" depending on how I need to set the "display: blah;" in the CSS. Oh! And make sure your show and/or hide class is the first one listed!
And then in your page it looks like this:
Add to the header:
Code: Select all
<script type="text/javascript">
function changeClass(targetID, classA, classB){
var node = document.getElementById(targetID);
var currentClasses = node.className.split(' ');
var currentFirstClass = currentClasses[0];
if(currentFirstClass == classA){
currentClasses[0] = classB;
}else if(currentFirstClass == classB){
currentClasses[0] = classA;
}
node.className = currentClasses.join(' ');
}
</script>
And then in your page it looks like this:
Code: Select all
<span onClick="changeClass('div_unique_id', 'showBlock', 'hide');" style="cursor: pointer;">Show More</span>
<div id="div_unique_id" class="hide">
Your Text to Show and Hide...</div>
Last edited by Benjamin on Mon Jun 29, 2009 10:32 am, edited 1 time in total.
Reason: Changed code type from text to javascript.
Reason: Changed code type from text to javascript.
Re: "Read More>>" link ?
Do you want to do this client-side, as in, when they click "Read More>>" the article expands instantly? If so, I'll move this to the "Javascript" forum.
Or server-side, as in, when they click "Read More>>" they get taken to another page that shows the whole article? If so, I'll move this to the "PHP - Code" forum.
Or server-side, as in, when they click "Read More>>" they get taken to another page that shows the whole article? If so, I'll move this to the "PHP - Code" forum.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: "Read More>>" link ?
@ client side ....
Re: "Read More>>" link ?
Did my code work for you Nits?
Re: "Read More>>" link ?
omniuni wrote:Did my code work for you Nits?
hey it works...
actually i made a spelling mistake while using it.
thanx alot buddy .