| Usuario |
Enlazar 2 scripts... |
Desconocido
|
| Enviado - 27/5/2004 |
| |
Hola a todos, he posteado este mensaje en varios foros de javascript, y no han sabido darme respuesta.. espero que aqui la consiga...
Bueno pues mi problema es el siguiente. Estoy trabajando con php haciendo una pagina web, y tengo dos escripts, uno que muestra en la barra de estado del explorador un porcentaje de lo que lleva cargada la pagina (va de 0 a 100 %) y el otro que muestra texto aleatorio tambien en la barra de estado del explorador.
A mi me gustaria que primero se ejecutara el de cargar la pagina y una vez cargada que ejecutara el segundo ya.
Si los pongo uno detras de otro se entremezclan los dos, y es un desastre.
¿hay alguna forma de llamar al segundo script cuando acabe el primero?
El segundo deberia de quedarse ya todo el rato en funcionamineto, osea el resultado final seria:
1 - Se ejecuta el script de carga de la pagina, y cuando llega al 100% llama al script de texto aleatorio.
2 - El script de texto aleatorio se queda ya hasta que se vuelva a recargar la pagina.
Bueno pues paso a colgar los dos scripts. Espero que tengamos suerte y podamos arreglarlo.
1 - Script (carga de la pagina)
<SCRIPT language=VBScript>
<!--
Dim Bar, Line, SP
Bar = 0
Line = "|"
sP = 250
Function Window_onLoad()
Bar = 95
sP = 10
END Function
Function Count()
If Bar < 100 Then
Bar = Bar + 1
Window.Status = "Cargando : " & Bar & "%" & " " & String(Bar, Line)
setTimeout "Count()", SP
Else
Window.Status = "Bienvenidos"
Document.Body.Style.Display = ""
End If
End Function
Call Count()
-->
</SCRIPT>
2 - Script de texto aleatorio.
<script language="JavaScript">
<!--
// Copyright (c) 1996-1997 Tomer Shiran. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.geocities.com/~yehuda/
// set speed of banner (pause in milliseconds between characters)
var speed = 50 // decrease value to increase speed (must be positive)
// set pause between completion of message and beginning of following message
var pause = 3000 // increase value to increase pause
// set initial values
var timerID = null
var bannerRunning = false
// create global array
var ar = new Array()
// assign the strings to the array's elements
ar[0] = " Mensaje 1 "
ar[1] = " Mensaje 2 "
ar[2] = " Mensaje 3 "
ar[3] = " Mensaje 4 "
ar[4] = " Mensaje 5 "
ar[5] = " Mensaje 6 "
ar[6] = " Mensaje 7 "
ar[7] = " Mensaje 8 "
// set index of first message to be displayed first
var currentMessage = 0
// set index of last character to be displayed first
var offset = 0
// stop the banner if it is currently running
function stopBanner() {
// if banner is currently running
if (bannerRunning)
// stop the banner
clearTimeout(timerID)
// timer is now stopped
bannerRunning = false
}
// start the banner
function startBanner() {
// make sure the banner is stopped
stopBanner()
// start the banner from the current position
showBanner()
}
// type-in the current message
function showBanner() {
// assign current message to variable
var text = ar[currentMessage]
// if current message has not finished being displayed
if (offset < text.length) {
// if last character of current message is a space
if (text.charAt(offset) == " ")
// skip the current character
offset++
// assign the up-to-date to-be-displayed substring
// second argument of method accepts index of last character plus one
var partialMessage = text.substring(0, offset + 1)
// display partial message in status bar
window.status = partialMessage
// increment index of last character to be displayed
offset++ // IE sometimes has trouble with "++offset"
// recursive call after specified time
timerID = setTimeout("showBanner()", speed)
// banner is running
bannerRunning = true
} else {
// reset offset
offset = 0
// increment subscript (index) of current message
currentMessage++
// if subscript of current message is out of range
if (currentMessage == ar.length)
// wrap around (start from beginning)
currentMessage = 0
// recursive call after specified time
timerID = setTimeout("showBanner()", pause)
// banner is running
bannerRunning = true
}
}
// -->
</script>
<script
language="JavaScript"> <!--
startBanner()
// -->
</script>
Un saludo y gracias de antemano!! |
| |
|
Desconocido
|
| Enviado - 30/5/2004 |
| |
pues supongo que solo tienes que hacer la llamada despues de que se haya cargadopor completo la pagina esto es poniendo la llamada en el <Body onLoad="llamada()">
|
| |
|
|
|