Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/11/2010, 16:32
txemaker
 
Fecha de Ingreso: octubre-2007
Mensajes: 74
Antigüedad: 16 años, 7 meses
Puntos: 1
Pregunta Por favor ayuda con este codigo

Hola amigos, he encontrado este codigo, pero no me sirve exactamente:

Me gustaría agregar un banner que corra por la pantalla (con el contacto de mi web) pero tengo el problema que no para de correr hacia el final de la página y no tiene fin ... y tambien tengo problemas a la hora de colocarlo en el punto exacto donde tiene que partir, ¿que campos debo modificar? ¿alguien puede explicarme los valores por favor? Por ultimo tampoco se donde modificar la opción para que no pueda cerrarse el banner...



Cita:
<html>
<head>
<!-- Empesando el codigo -->
<style type="text/css">
#topbar{
position:absolute;
border: 0px solid black;
padding: 5px;
background-color: ;
width: 500px;
visibility: hidden;
z-index: 200;
top: 27px;
height: 300px;
left: 13px;
}
img {
border: none;
}
</style>

<script type="text/javascript">
var persistclose=0 //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
var startX = 10 //set x offset of bar in pixels
var startY = 7 //set y offset of bar in pixels
var verticalpos="fromtop" //enter "fromtop" or "frombottom"

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(off set, end))
}
}
return returnvalue;
}

function closebar(){
if (persistclose)
document.cookie="remainclosed=1"
document.getElementById("topbar").style.visibility ="hidden"
}

function staticbar(){
barheight=document.getElementById("topbar").offset Height
var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
var d = document;
function ml(id){
var el=d.getElementById(id);
if (!persistclose || persistclose && get_cookie("remainclosed")=="")
el.style.visibility="visible"
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.left=x+"px";this.st yle.top=y+"px";};
el.x = startX;
if (verticalpos=="fromtop")
el.y = startY;
else{
el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
el.y -= startY;
}
return el;
}
window.stayTopLeft=function(){
if (verticalpos=="fromtop"){
var pY = ns ? pageYOffset : iecompattest().scrollTop;
ftlObj.y += (pY + startY - ftlObj.y)/8;
}
else{
var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
ftlObj.y += (pY - startY - ftlObj.y)/8;
}
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopLeft()", 10);
}
ftlObj = ml("topbar");
stayTopLeft();
}

if (window.addEventListener)
window.addEventListener("load", staticbar, false)
else if (window.attachEvent)
window.attachEvent("onload", staticbar)
else if (document.getElementById)
window.onload=staticbar
</script>



</head>
<body>
<div id="topbar">
<p align="right"><a href="" onClick="closebar(); return false"><img src="RUTA DE LA IMAGEN PARA CERRAR(x) EL POP UP" border="0" /></a>
</align>
Aqui poner el texto codigo que se desee<br> o si se deesea una imagen, o <br> publicidad de google</td>
</div>
<!-- Terminando el codigo -->

</body>
</html>


Actualmente lo estoy haciendo con el siguiente codigo, pero no funciona con Mozilla Firefox:

Cita:
<body>

<div id="capa" style="position:absolute; top: 822 px; width: 344 px; color: #555555 ;">

<IMG SRC="telefonos.jpg" WIDTH=283 HEIGHT=340">


<script language="JavaScript" type="text/javascript">

var capa =
{
topMargin : 0 , //posicion inicial
ceiling : 822 , //pixels del efecto de amortiguacion
desplazaTime : 2500 , //tiempo en recorrer la distancia anterior
capaDiv : document.all ? document.all.capa :
(document.layers ? document.capa : document.getElementById('capa'))
}

window.setInterval("capa.coordenadas( )", 5)

capa.coordenadas = function( )
{
if(document.all)
{
this.actualY = this.capaDiv.style.pixelTop;
this.scrollTop = document.body.scrollTop;
}
else if(document.layers)
{
this.actualY = this.capaDiv.top;
this.scrollTop = window.pageYOffset;
}
else if(document.getElementById)
{
this.actualY = parseInt(this.capaDiv.style.top);
this.scrollTop = window.pageYOffset;
}

var nuevoScrollTop = Math.max( this.scrollTop + this.topMargin, this.ceiling );

if ( this.actualY != nuevoScrollTop )
{
if ( nuevoScrollTop != this.targetY )
{
this.targetY = nuevoScrollTop;
this.desplazaInit( );
}
this.desplaza( );
}
}

capa.desplazaInit = function( )
{
var ahora = new Date( )
this.A = this.targetY - this.actualY ;
this.B = Math.PI / ( 2 * this.desplazaTime );
this.C = ahora.getTime( );
this.D = this.actualY;
}

capa.desplaza = function( )
{
var ahora = new Date( );
var nuevaY = this.A * Math.sin( this.B * ( ahora.getTime( ) - this.C ) ) + this.D;
nuevaY = Math.round( nuevaY );

if ( ( this.A > 0 && nuevaY > this.actualY ) || ( this.A < 0 && nuevaY < this.actualY ) )
{
if (document.all)
this.capaDiv.style.pixelTop = nuevaY;
else if(document.layers)
this.capaDiv.top = nuevaY;
else if(document.getElementById)
this.capaDiv.style.top = nuevaY;
}
}

</script>

</body>
Muchas gracias amigos, un saludo.