Foros del Web » Programando para Internet » Javascript »

No consigo que salgan en el centro

Estas en el tema de No consigo que salgan en el centro en el foro de Javascript en Foros del Web. Necesito que alguien me ayude con esto,el problema es que cuando le doy a vista preliminar me sale en una esquina y yo lo que ...
  #1 (permalink)  
Antiguo 17/04/2003, 13:39
 
Fecha de Ingreso: abril-2003
Mensajes: 5
Antigüedad: 21 años
Puntos: 0
No consigo que salgan en el centro

Necesito que alguien me ayude con esto,el problema es que cuando le doy a vista preliminar me sale en una esquina y yo lo que quiero es q el cuadro me salga en el centro de la pagina, he intentado arreglarmelas cambiandole cosas pero no doy con la tela.Debajo de este tb hay otro Java con el que me ocurre lo mismo, las frases salen por toda la pantalla y yo solo quiero que me salgan por el centro, si alguien me puede ayudar se lo agradecere sino gracias de todas formas
<html>
<head>

<body>
<script language="JavaScript1.2">

var delay=3000 //pausa (en milisegundos)
var fcontent=new Array()
begintag='<font face="Arial" size=2>' //tag que abre los mensajes
fcontent[0]="<b>Ejemplo...</b><br><br>Crear un sitio web es relativamente fácil. Lo dificil es darle un buen contenido, diseño y enfoque"
fcontent[1]="El tener en un mismo sitio, mas de 3 paginas de informacion, cansa al visitante y lo hace dejar el sitio."
fcontent[2]="Una de las causas por las que el visitante regresa a un sitio frecuentemente es porque bla, bla, bla."
closetag='</font>'

var fwidth=150 //ancho
var fheight=150 //alto

///No editar/////////////////

var ie4=document.all&&!document.getElementById
var ns4=document.layers
var DOM2=document.getElementById
var faderdelay=0
var index=0

if (DOM2)
faderdelay=2000

//function to change content
function changecontent(){
if (index>=fcontent.length)
index=0
if (DOM2){
document.getElementById("fscroller").style.color=" rgb(255,255,255)"
document.getElementById("fscroller").innerHTML=beg intag+fcontent[index]+closetag
colorfade()
}
else if (ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag
else if (ns4){
document.fscrollerns.document.fscrollerns_sub.docu ment.write(begintag+fcontent[index]+closetag)
document.fscrollerns.document.fscrollerns_sub.docu ment.close()
}

index++
setTimeout("changecontent()",delay+faderdelay)
}

// colorfade() partially by Marcio Galli for Netscape Communications. ////////////

frame=20;
hex=255 // Initial color value.

function colorfade() {
// 20 frames fading process
if(frame>0) {
hex-=12; // increase color value
document.getElementById("fscroller").style.color=" rgb("+hex+","+hex+","+hex+")"; // Set color value.
frame--;
setTimeout("colorfade()",20);
}
else{
document.getElementById("fscroller").style.color=" rgb(0,0,0)";
frame=20;
hex=255
}
}

if (ie4||DOM2)
document.write('<div id="fscroller" style="border:1px solid black;width:'+fwidth+';height:'+fheight+';padding: 2px"></div>')

window.onload=changecontent
</script>


<ilayer id="fscrollerns" width=&{fwidth}; height=&{fheight};><layer id="fscrollerns_sub" width=&{fwidth}; height=&{fheight}; left=0 top=0></layer></ilayer>

</body>
</html>



SEGUNDO JAVA

<!--

Quotation Scroller v1.0 by Angus Turnbull http://gusnz.cjb.net Updated: 15 Feb 2001
Secondary Redirect: http://www.bigfoot.com/~angus_rt

-->

<html>
<body bgcolor="#ffffff" scroll="no">

<script>
<!-- // Hide

var isDOM = false, isNS4 = false;
if (document.all) var isDOM = true, docObj = 'document.all.', styObj = '.style';
else if (document.layers) var isNS4 = true, docObj = 'document.', styObj = '';

var quotes = new Array(); c = 0;
quotes[c] = 'So Long, And Thanks For All The Fish'; c++;
quotes[c] = 'Yomama so...'; c++;
quotes[c] = 'Nothing lasts forever but the tomato'; c++;
quotes[c] = 'mmmm... chocolaaateahrghlly...'; c++;
quotes[c] = 'Very funny Scotty, now beam down my clothes!'; c++;
quotes[c] = 'Who let the dogs out?'; c++;
quotes[c] = 'Dang it... the boy ain\'t right'; c++;
quotes[c] = 'Shrimp gumbo, shrimp patties, shrimp...'; c++;
quotes[c] = 'Och aye th\' noo!'; c++;
quotes[c] = 'Respect my authoritaah!'; c++;
quotes[c] = 'So cunning you could stick a tail on it and call it a weasel'; c++;
quotes[c] = 'And I\'d say, "Oi! You! NO!"'; c++;
quotes[c] = 'That\'s a one, spicy! meat-a-ball!'; c++;
quotes[c] = 'The world is a vampire...'; c++;
quotes[c] = 'This is the quote that never ends...'; c++;
quotes[c] = 'Screeew you guys, I\'m going home'; c++;
quotes[c] = 'The Earth is full. Go home!'; c++;
quotes[c] = 'So many pedestrians, so little time...'; c++;

var visQuotes = 10; // Maximum onscreen at once.

var sDivSty = new Array(visQuotes);
var sDivRef = new Array(visQuotes);
var speed = new Array(visQuotes);

// Left: Low speed colours (lighter) .... Right: High speed colours (darker).
var colours = new Array('B2C7DE','A4BCD8','96B2D2','88A8CC','7A9EC6' ,'6C94C0','5E89BA');


function checkDivs()
{
for (i = 0; i < visQuotes; i++)
{
// If it's moved offscreen to the left (or starting), set things in motion...
if (parseInt(sDivSty[i].left) < (0 - (isDOM ? sDivRef[i].clientWidth : sDivSty[i].clip.width)))
{
speed[i] = Math.floor(Math.random() * 56) + 8; // Varies: 8 to 63.
// Off to the right it goes.
sDivSty[i].left = (isDOM ? document.body.clientWidth : window.innerWidth) + Math.random() * 50;
// Write a quote in a colour that depends on the speed.

/* Stylesheets - guess which browser has bugs :)
*
* divText = '<nobr><span style="font: ' + speed[i] + 'px Arial, Helvetica; ' +
* 'color: #' + colours[Math.floor(speed[i] / 8) - 1] + '">' +
* quotes[Math.floor(Math.random() * quotes.length)] + '</span></nobr>';
*/

fontSize = Math.floor(speed[i] / 8) - 1;
divText = '<nobr><font face="Arial, Helvetica" size="' + fontSize + '" color="#' +
colours[fontSize] + '">' + quotes[Math.floor(Math.random() * quotes.length)] +
'</font></nobr>';

if (isDOM) sDivRef[i].innerHTML = divText;
if (isNS4)
{
sDivRef[i].document.write(divText);
sDivRef[i].document.close();
}
// Position and layer it according to its speed (faster = higher).
sDivSty[i].zIndex = speed[i];
topMax = (isDOM ? document.body.clientHeight : innerHeight) - speed[i];
sDivSty[i].top = topMax * Math.random();
}
// All items: Keep 'em moving left.
sDivSty[i].left = parseInt(sDivSty[i].left) - (speed[i] / 4);
}
}


function initDivs()
{
for (i = 0; i < visQuotes; i++)
{
divID = 'sDiv' + i.toString();
if (isDOM) document.write('<div id="' + divID + '" style="position: absolute; left: -1000">&nbsp;</div>');
// Have to use layers, divs are buggy as..... in NS. Again.
if (isNS4) document.write('<layer id="' + divID + '" left="-1000">&nbsp;</layer>');
sDivRef[i] = eval(docObj + 'sDiv' + i);
sDivSty[i] = eval(docObj + 'sDiv' + i + styObj);
}

setInterval('checkDivs()', 50);
}

if (isDOM || isNS4) initDivs();

// End Hide -->
</script>

<div id="mainText" style="position: absolute; left: 100; top: 200; z-index: 100">
<h1>'Ello 'ello 'ello what 'ave we 'ere then?</h1>
<div>

</body>
</html>
  #2 (permalink)  
Antiguo 18/04/2003, 18:48
Avatar de atlante  
Fecha de Ingreso: julio-2002
Ubicación: Lima
Mensajes: 140
Antigüedad: 21 años, 9 meses
Puntos: 0
bueno .....

Bueno veamos , el primero es muy simple solo se cambia los valores left y top de la capa :
Código PHP:
<html>
<
head>

<
body>
<
script language="JavaScript1.2">

var 
delay=3000 //pausa (en milisegundos)
var fcontent=new Array()
begintag='<font face="Arial" size=2>' //tag que abre los mensajes
fcontent[0]="<b>Ejemplo...</b><br><br>Crear un sitio web es relativamente fácil. Lo dificil es darle un buen contenido, diseño y enfoque"
fcontent[1]="El tener en un mismo sitio, mas de 3 paginas de informacion, cansa al visitante y lo hace dejar el sitio."
fcontent[2]="Una de las causas por las que el visitante regresa a un sitio frecuentemente es porque bla, bla, bla."
closetag='</font>'

var fwidth=150 //ancho
var fheight=150 //alto

///No editar/////////////////

var ie4=document.all&&!document.getElementById
var ns4=document.layers
var DOM2=document.getElementById
var faderdelay=0
var index=0

if (DOM2)
faderdelay=2000

//function to change content
function changecontent(){
if (
index>=fcontent.length)
index=0
if (DOM2){
document.getElementById("fscroller").style.color="rgb(255,255,255)"
document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
colorfade
()
}
else if (
ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag
else if (ns4){
document.fscrollerns.document.fscrollerns_sub.document.write(begintag+fcontent[index]+closetag)
document.fscrollerns.document.fscrollerns_sub.document.close()
}

index++
setTimeout("changecontent()",delay+faderdelay)
}

// colorfade() partially by Marcio Galli for Netscape Communications. ////////////

frame=20;
hex=255 // Initial color value.

function colorfade() { 
// 20 frames fading process
if(frame>0) { 
hex-=12// increase color value
document.getElementById("fscroller").style.color="rgb("+hex+","+hex+","+hex+")"// Set color value.
frame--;
setTimeout("colorfade()",20); 
}
else{
document.getElementById("fscroller").style.color="rgb(0,0,0)";
frame=20;
hex=255

}

if (
ie4||DOM2)
document.write('<div id="fscroller" style="position:absolute;left:300px;top:150px;border:1px solid black;width:'+fwidth+';height:'+fheight+';padding:2px"></div>')

window.onload=changecontent
</script>


<ilayer id="fscrollerns" width=&{fwidth}; height=&{fheight};><layer id="fscrollerns_sub" width=&{fwidth}; height=&{fheight}; left=0 top=0></layer></ilayer>

</body>
</html> 
ahora el segundo , ese si que es un problema , utiliza muchas funciones matematicas , y encontrar el valor exacto es mas trabajoso... pero bueno estoy osioso hoy asi que aqui va :
Código PHP:
<html>
<
body bgcolor="#ffffff" scroll="no">

<
script>
<!-- 
// Hide

var isDOM falseisNS4 false;
if (
document.all) var isDOM truedocObj 'document.all.'styObj '.style';
else if (
document.layers) var isNS4 truedocObj 'document.'styObj '';

var 
quotes = new Array(); 0;
quotes[c] = 'So Long, And Thanks For All The Fish'c++;
quotes[c] = 'Yomama so...'c++;
quotes[c] = 'Nothing lasts forever but the tomato'c++;
quotes[c] = 'mmmm... chocolaaateahrghlly...'c++;
quotes[c] = 'Very funny Scotty, now beam down my clothes!'c++;
quotes[c] = 'Who let the dogs out?'c++;
quotes[c] = 'Dang it... the boy aint right'c++;
quotes[c] = 'Shrimp gumbo, shrimp patties, shrimp...'c++;
quotes[c] = 'Och aye the noo!'c++;
quotes[c] = 'Respect my authoritaah!'c++;
quotes[c] = 'So cunning you could stick a tail on it and call it a weasel'c++;
quotes[c] = 'And Id say, "Oi! You! NO!"'c++;
quotes[c] = 'Thats a one, spicy! meat-a-ball!'c++;
quotes[c] = 'The world is a vampire...'c++;
quotes[c] = 'This is the quote that never ends...'c++;
quotes[c] = 'Screeew you guys, Im going home'c++;
quotes[c] = 'The Earth is full. Go home!'c++;
quotes[c] = 'So many pedestrians, so little time...'c++;

var 
visQuotes 10// Maximum onscreen at once.

var sDivSty = new Array(visQuotes);
var 
sDivRef = new Array(visQuotes);
var 
speed = new Array(visQuotes);

// Left: Low speed colours (lighter) .... Right: High speed colours (darker).
var colours = new Array('B2C7DE','A4BCD8','96B2D2','88A8CC','7A9EC6'
,'6C94C0','5E89BA');


function 
checkDivs()
{
for (
0visQuotesi++)
{
// If it's moved offscreen to the left (or starting), set things in motion...
if (parseInt(sDivSty[i].left) < (- (isDOM sDivRef[i].clientWidth sDivSty[i].clip.width)))
{
speed[i] = Math.floor(Math.random() * 56) + 8// Varies: 8 to 63.
// Off to the right it goes.
sDivSty[i].left = (isDOM document.body.clientWidth window.innerWidth) + Math.random() * 50;
// Write a quote in a colour that depends on the speed.

/* Stylesheets - guess which browser has bugs :)
*
* divText = '<nobr><span style="font: ' + speed[i] + 'px Arial, Helvetica; ' +
* 'color: #' + colours[Math.floor(speed[i] / 8) - 1] + '">' +
* quotes[Math.floor(Math.random() * quotes.length)] + '</span></nobr>';
*/

fontSize Math.floor(speed[i] / 8) - 1;
divText '<nobr><font face="Arial, Helvetica" size="' fontSize '" color="#' +
colours[fontSize] + '">' quotes[Math.floor(Math.random() * quotes.length)] +
'</font></nobr>';

if (
isDOMsDivRef[i].innerHTML divText;
if (
isNS4)
{
sDivRef[i].document.write(divText);
sDivRef[i].document.close();
}
// Position and layer it according to its speed (faster = higher).
sDivSty[i].zIndex speed[i];
topMax 100//(isDOM ? document.body.clientHeight : innerHeight) - speed[i];
sDivSty[i].top topMax Math.random() + 140;
}
// All items: Keep 'em moving left.
sDivSty[i].left parseInt(sDivSty[i].left) - (speed[i] / 4);
}
}


function 
initDivs()
{
for (
0visQuotesi++)
{
divID 'sDiv' i.toString();
if (
isDOMdocument.write('<div id="' divID '" style="position: absolute; left: -1000"> </div>');
// Have to use layers, divs are buggy as..... in NS. Again.
if (isNS4document.write('<layer id="' divID '" left="-1000"> </layer>');
sDivRef[i] = eval(docObj 'sDiv' i);
sDivSty[i] = eval(docObj 'sDiv' styObj);
}

setInterval('checkDivs()'50);
}

if (
isDOM || isNS4initDivs();

// End Hide -->
</script>


</body>
</html>

solo cambie el valor maximo del ancho  de las capas y la distancia del borde superior.. 
__________________
If you look, If you really read between the lines, You will see...

Última edición por atlante; 18/04/2003 a las 19:00
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:34.