Hi,

Is there any way to end a line of text with three dot if this one is too long for the content box/site layout? Someting like wrap text but without going to the next line.

Thanks for your help

Recommended Answers

All 3 Replies

Hi,

Is there any way to end a line of text with three dot if this one is too long for the content box/site layout? Someting like wrap text but without going to the next line.

Thanks for your help

it is very easy to do with javascript as follows:

copy paste the code below into body section of your page for a demo, the process is very simple :

<script>
function SplitText(text,count)
{
if(text.length > count)
{
text = text.substring(0,(count-1));
text = text + "...";
}
return text;
}
</script>
<script>
function demo()
{
newText = SplitText(document.getElementById('Text1').value,10);
alert(newText);
}
</script>
<input id="Button1" type="button" value="button" onclick="demo()" />
<input id="Text1" type="text" />

Serkan Şendur

Hey. I want to do something similar to what you have done but not exactly the same.

I have a RSS feed that is embedded in my site. I would like to make it so if the title is longer than one line of the box that it is inside (266px wide) it will cut it off and put "...".

Is this possible? If not, is there a way of getting it to scroll the text? That may be an even better idea than cutting it off...... hmmmm?

Thanks
~Joel

Hey. I want to do something similar to what you have done but not exactly the same.

I have a RSS feed that is embedded in my site. I would like to make it so if the title is longer than one line of the box that it is inside (266px wide) it will cut it off and put "...".

Is this possible? If not, is there a way of getting it to scroll the text? That may be an even better idea than cutting it off...... hmmmm?

Thanks
~Joel

you can still use the same function, you are going to calculate just the number that you are going to pass as an argument because function can not know how many characters are equal to 266 px, try couple times, pass 100, pass 50, pass 150, you will understand what you should pass.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.