Ted k’ É assim que tem que ser! Programando em ASP, ASP.NET, PHP, CSS, dentre outras…

4
Nov/08
0



Função “três pontinhos”

Código simples para você ter aqueles "três pontinhos" em sua notícia, feeds etc...

 

Usando VBScript

<%@ Language="VBScript" %>
<%
Public Function Pontos(VarTexto, Max) ' Recebemos os valores
	If Int(Len(VarTexto)) > Max Then
		Response.Write(Left(VarTexto, Max)&"...") ' Usamos a função "substring" para fazer os cortes
	Else
		Response.Write(VarTexto)
	End If
End Function

Texto = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the whenwhen, when an unknown printer took a galley of type and scrambled it to make a type specimen book."

Call Pontos(Texto, 150) ' Chamando a função e mostrando o resultado
%>

 

 

Agora usando JScript com ASP

<%@ Language="JScript" %>
<%
function pontos(varTexto, Max) { // Recebemos os valores
	if (varTexto.length > Max) {
		Response.Write(varTexto.substring(0, Max)+"..."); // Usamos a função "substring" para fazer os cortes
	}
	else {
		Response.Write(varTexto);
	}
}

texto = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the whenwhen, when an unknown printer took a galley of type and scrambled it to make a type specimen book.";

pontos(texto, 150); // Chamando a função e mostrando o resultado
%>
Comentários (0) Trackbacks (0)

Ainda não há comentários.



Deixe um comentário.


Não há trackbacks ainda.


Portfólio Ted k'

Atualize seu Navegador