Questo semplice script consente di mostrare a video, tramite l'aiuto di un codice Javascript, dei dati estrapolati con una query SQL da un database.
L'utilizzo potrà essere quello di mostrare delle news in tempo reale ogni volta che viene ricaricata la pagina.
<% Set Conn =Server.CreateObject("ADODB.Connection") Conn.Open strConn strSQL = "SELECT * FROM news ORDER BY data " Set RS = Server.CreateObject("ADODB.Recordset") RS.Open strSQL, Conn do while not RS.EOF strtesto = strtesto & "<b>" & RS("data") &"</b> " & _ RS("testo") & " " RS.MoveNext loop RS.Close Set RS = Nothing Conn.Close Set Conn = Nothing %> <table align="center"> <tr> <td width="16">News: </td> <td> <script language="JavaScript1.2"> var marqueewidth=504 var marqueeheight=10 var speed=4 var marqueecontents='<div class=testoscroll><%= Replace(strtesto, "'", "\'") %></div>' if (document.all) document.write('<marquee direction="left" scrollAmount='+speed+' style="width:'+marqueewidth +';height:'+marqueeheight+'">' +marqueecontents+'</marquee>') function regenerate(){ window.location.reload() } function regenerate2(){ if (document.layers){ setTimeout("window.onresize=regenerate",450) intializemarquee() } } function intializemarquee(){ document.cmarquee01.document.cmarquee02.document.write( marqueecontents) document.cmarquee01.document.cmarquee02.document.close() thelength=document.cmarquee01.document.cmarquee02.document.height scrollit() } function scrollit(){ if (document.cmarquee01.document.cmarquee02.top>=thelength*(-1)){ document.cmarquee01.document.cmarquee02.top-=speed setTimeout("scrollit()",100) }else{ document.cmarquee01.document.cmarquee02.top = marqueeheight scrollit() } } window.onload=regenerate2 </script> </td> </tr> </table>
Commenti
Per inserire un commento, devi avere un account.
Fai il login e torna a questa pagina, oppure registrati alla nostra community.
Approfondimenti
Filtrare e rimuovere gli elementi dalla cache del browser tramite le API JavaScript
Utilizzare le Cache API di JavaScript per salvare elementi nella cache del browser
Generare file per il download da Blazor WebAssembly
Recuperare un elemento inserito nella cache del browser tramite API JavaScript
Load test di ASP.NET Core con k6
Eseguire operazioni con timeout in React