Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 17
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2004
    Messaggi
    89

    CARICARE CODICE ASP TRAMITE JAVASCRIPT

    Buongiorno a tutti, sto pensando di fare un content manager, sono arriva a buon punto solo che vorrei che la pagina che genera il sommario degli aticoli contenuti nel database venga caricata nella pagina dell'utente...
    ho provato tre diversi metodi ma non funzionano bene:
    1- Usando il codice:
    questo metodo non lo posso utilizzare perchè la pagina da caricare include altri file, e essendo in una directory diverda da quella dove viene caricata mi da errori.
    2- Usando il codice: <% Server.Execute("./paginadacaricare.asp") %>
    la stessa cosa di quello sopra...

    Poi gurdando nel codice di un content manager (www.xigla.com), Absolute news manager...ho visto che la pagina che genera il sommario viene caricata dal codice: <script language="JavaScript" src="/newsmanager/xlaabsolutenm.asp?z=1"></script>. Sostituendo il nome con quello della mia pagina non funziona, cioè non mi visualizza niente...
    Sapete spiegarmi come devo risolvere questo problema???

    Grazie a tutti
    Marco

  2. #2
    Qualunque file chiami dentro javascript deve restituire dei document.write('testo o codice html');

  3. #3
    Perchè non puoi usare degli include? Se i file da includere sono in un'altra cartella, farai

    E' nato www.lombardiamotori.it

    www.universocase.it: il primo portale italiano di annunci immobiliari gratuiti e autogestiti!

  4. #4
    Utente di HTML.it
    Registrato dal
    Jul 2004
    Messaggi
    89
    Grazie per le vostre immediate soluzioni, ma mi sono dimenticato di dirvi che dev o anche passare il valore di una o piu variabili, quindi credo che con l'include non sia possibile...per quanto riguarda il document.write, devo utilizzarlo nella pagina che richiamo tramite javascript? e dove, al posto dei response.write? e poi come faccio a fare scrivere i valori delle variabili ASP nel document.write? puoi spiegarti meglio e grazie mille per l'aiuto...

  5. #5
    Originariamente inviato da allways
    Grazie per le vostre immediate soluzioni, ma mi sono dimenticato di dirvi che dev o anche passare il valore di una o piu variabili, quindi credo che con l'include non sia possibile...per quanto riguarda il document.write, devo utilizzarlo nella pagina che richiamo tramite javascript? e dove, al posto dei response.write? e poi come faccio a fare scrivere i valori delle variabili ASP nel document.write? puoi spiegarti meglio e grazie mille per l'aiuto...
    pagina chiamata dentro il javascript:
    codice:
    <%
    ' codice asp...
    ' esempio:
    nome = "pippo"
    %>
    document.write('<%=nome%>');
    Attenzione: per non mandare in errore il javascript devi fare la replace di tutti i carattere apice singolo con \'
    esempio:
    codice:
    <%
    ' codice asp...
    ' esempio:
    nome = "Valle D'Aosta"
    nome = replace(nome,"'","\'")
    %>
    document.write('<%=nome%>');

  6. #6
    Utente di HTML.it
    Registrato dal
    Jul 2004
    Messaggi
    89
    Praticamente dovrei mettere ogni response.write dentro un document.write?
    Inoltre io avrei nella pagina da caricare molti tag html che se presenti generano un errore quando vengono caricati, quindi dovrei mettere tutti i tag html dentro i document.write?
    (Però guardando il codice della pagina che usava quel programma della xigla non viene usato alcun document.write ma solo il response.write non capisco perchè...)
    Grazie ancora......

  7. #7
    codice:
    document.write('<table width="500">');
    document.write('<tr>');
    document.write('td align="center">');
    document.write('<%=datoASP%>');
    ECCETERA...
    Se ci fai vedere quella pagina dell xigla...

  8. #8
    Utente di HTML.it
    Registrato dal
    Jul 2004
    Messaggi
    89
    Ecco qui la pagina che viene caricata dal codice javascript:





    <%
    response.buffer=true
    response.flush
    zoneid=request("z")
    if instr(zoneid,"$")<>0 or zoneid="" then response.end
    nocache=request("nocache")
    fdate=request("fdate")
    if fdate<>"" then zonecache=""

    '/// Check Protection ///
    callingurl=lcase(Request.ServerVariables("HTTP_REF ERER"))
    if zoneprotection<>"any" and instr(callingurl,lcase(applicationurl))=0 and callingurl<>"" then
    specialurls=split(lcase(specialurls),";")
    for x=0 to ubound(specialurls)
    if len(specialurls(x))>5 then
    if instr(specialurls(x),"http://")=0 then specialurls(x)="http://"&specialurls(x)
    if instr(callingurl,specialurls(x))=1 then
    takeaction=true
    exit for
    end if
    end if
    next
    if zoneprotection="restricted" and takeaction=false then response.end
    if zoneprotection="banned" and takeaction=true then response.end
    end if

    '/// Zone Cache ///
    if zonecache<>"" then
    dim resultfile
    resultfile=""
    call getcache("zone",nocache)
    end if

    '//// Override Default Parameters
    articlespz=request("h") 'Number of headlines 0-Unlimited
    showsummary=request("ss") 'Show Summary Y,N
    showsource=request("sc") 'Show Source Y,N
    showdates=request("sd") 'Show Dates Y,N
    showtn=request("st") 'Show Thumbnail Y,N
    displayhoriz=request("d") 'Display V-Vertical, H-Horizontal
    textalign=request("al") 'Align
    cellcolor=request("cc") 'Cell Color
    targetframe=request("target") 'Targetframe
    zonefont=request("font") 'Font
    fontcolor=request("color") 'Font Color
    fontsize=request("size") 'Font Size
    isarchive=request("isarchive") 'List only Archives
    stdate=request("stdate") 'With Start Date Like
    edate=request("edate") 'With End Date Like
    pdate=request("pdate") 'With Posted Date Like
    hdate=request("hdate") 'With Headline Date Like
    sort=request("sort") 'Sorting Criteria
    ord=request("ord") 'Order (asc,desc)


    today=year(now)&"/"&right("0"&month(now),2)&"/"&right("0"&day(now),2)
    if fdate<>"" then today=fdate

    psql="select * from vArticlesZones where "
    if isnumeric(zoneid) then
    psql=psql & "zoneid="&zoneid
    else
    psql=psql & "zonename='"&zoneid&"'"
    end if

    if isarchive="" or isarchive="n" then psql=psql &" and status=1 " else psql=psql & "and status=4"

    if stdate="" and edate="" and pdate="" and hdate="" then
    psql=psql & " and startdate<='"&today&"' and (enddate>='"&today&"' or enddate='-')"
    else
    if stdate<>"" then psql=psql & " and startdate like '"&stdate&"%'"
    if edate<>"" then psql=psql & " and enddate like '"&edate&"%'"
    if pdate<>"" then psql=psql & " and posted like '"&pdate&"%'"
    if hdate<>"" then psql=psql & " and headlinedate like '"& hdate & "%'"
    end if

    if sort<>"" then psql=psql & "order by "&sort else psql=psql & " order by startdate "
    if ord<>"" then psql=psql & " " & ord

    set conn=server.createobject("ADODB.Connection")
    conn.open connection
    set rs=conn.execute(psql)
    if rs.eof then
    if nonewsmessage<>"" then articlelist="<div align=center>
    "&nonewsmessage&"
    </div>" else articlelist=""
    else
    '/// Headlines Per Zone
    if articlespz<>"" then
    articlespz=cint(articlespz)
    else
    articlespz=rs("articlespz")
    end if

    '/// Display Summary
    if showsummary="" then
    showsummary=rs("showsummary")
    elseif showsummary="n" then
    showsummary=""
    end if

    '/// Display Source
    if showsource="" then
    showsource=rs("showsource")
    elseif showsource="n" then
    showsource=""
    end if

    '/// Display Dates
    if showdates="" then
    showdates=rs("showdates")
    elseif showdates="n" then
    showdates=""
    end if

    '/// Display Thumbnail
    if showtn="" then
    showtn=rs("showtn")
    elseif showtn="n" then
    showtn=""
    end if

    '/// Display Articles Horizontally
    if displayhoriz="" then
    displayhoriz=rs("displayhoriz")
    elseif displayhoriz="v" then
    displayhoriz=""
    end if

    if zonefont="" then zonefont=rs("zonefont")
    if fontsize="" then fontsize=rs("fontsize")
    if fontcolor="" then fontcolor=rs("fontcolor")
    if fontcolor<>"" then fontcolor=" fontcolor='"&fontcolor&"'"
    if targetframe="" then targetframe=rs("targetframe")
    if targetframe<>"" then target=" target='"&targetframe&"'" else target=""
    if textalign="" then textalign=rs("textalign")
    if cellcolor="" then cellcolor=rs("cellcolor")
    if cellcolor<>"" then cellcolor=" bgcolor='"&cellcolor&"'"

    do until rs.eof
    closetag=""
    summary=rs("summary")&""
    sumary=server.htmlencode(summary)
    if rs("articleurl")<>"" and openexternal<>"" then thistarget="target=_blank" else thistarget=target
    c=c+1
    if rowmade="" or displayhoriz="" then articlelist=articlelist & "<tr>"
    if displayhoriz<>"" then rowmade="1"
    articlelist=articlelist & "<td align='"&textalign&"' width=[WIDTH] left valign=top "&cellcolor&">"
    if showtn<>"" then thisimage=gettnimage(rs("articleid"),textalign) else thisimage=""
    articlelist=articlelist & "<font face='"&zonefont&"' size='"&fontsize&"'"&fontcolor&">"
    if rs("article")<>"" or rs("articleurl")<>"" then articlelist=articlelist & "" : closetag=""

    articlelist=articlelist &thisimage&""&rs("headline")&"" & closetag & "</font>"

    if showdates<>"" and rs("headlinedate")<>"" then articlelist=articlelist & "
    <font face='"&zonefont&"' size='"&fontsize&"'"&fontcolor&">"&rs("headlinedate")&"</font>"
    if showsource<>"" and rs("source")<>"" then articlelist=articlelist & "
    <font face='"&zonefont&"' size='"&fontsize&"'"&fontcolor&">"&rs("source")&"</font>"
    if showsummary<>"" and summary<>"" then articlelist=articlelist & "
    <font face='"&zonefont&"' size='"&fontsize&"'"&fontcolor&">"&replace(summary ,vbcrlf,"
    ")&"</font>"
    if readmore<>"" then articlelist=articlelist &"
    <font face='"&zonefont&"' size='"&fontsize&"'"&fontcolor&">"
    if closetag<>"" then articlelist=articlelist & ""&readmore&""
    articlelist=articlelist &"</font>"
    articlelist=articlelist&"</td>"
    if displayhoriz="" then articlelist=articlelist & "</tr>"
    rs.movenext

    '/// Display Limited Articles ?
    if articlespz>0 and c>=articlespz then exit do
    loop

    '/// Get Appropiate Cell Width
    width="100%"
    if displayhoriz<>"" then
    if c=0 then c=1
    articlelist=articlelist & "</tr>"
    width=int(100/c)&"%"
    end if
    articlelist=replace(articlelist,"[WIDTH]",width)

    articlelist="<table width=100% cellspacing=1 cellpadding=3 border=0>"&articlelist&"</table>"
    end if
    rs.close
    set rs=nothing
    conn.close
    set conn=nothing

    articlelist=replace(articlelist,"\","\\")
    articlelist=replace(articlelist,"/","\/")
    articlelist=replace(articlelist,vbclrf,"\n")
    articlelist=replace(articlelist,chr(34),"\"&chr(34 ))
    articlelist=replace(articlelist,"'","\'")
    articlelist="document.write('"&articlelist&"');"

    '/// Do Cache ? ///
    if zonecache<>"" and resultfile<>"" then call writecache(resultfile,articlelist)

    response.write articlelist
    response.end
    %>

    Qui c'è anche il codice della pagina incCache.asp che viene inclusa
    <%
    cachefolder=server.mappath("cache/")
    cachetimeframe="h"
    function getcache(cachetype,nocache)
    whatfile=cachetype
    strSeparator = "_"
    For Each var In Request.QueryString
    if lcase(var)<>"nocache" then parameters = parameters & "_" & var & "_" & replace(Request.QueryString(var),"/","-")
    next
    whatfile=whatfile & parameters
    whatfile=cachefolder&"\"&whatfile&".htm"
    resultfile=whatfile

    if nocache<>"" then
    Set Fs=createobject("scripting.filesystemobject")
    if fs.fileexists(whatfile) then
    Set objFile = fs.GetFile(whatfile)
    itsdate = objFile.DateLastModified
    set objFile=nothing
    if datediff(cachetimeframe,itsdate,now)<cachetime then
    Set a=fs.opentextfile(whatfile)
    content=a.readall
    a.close
    set a=nothing
    set fs=nothing
    resultfile=""
    response.write content
    end if
    end if
    set fs=nothing
    if resultfile="" then response.end
    end if
    end function

    function writecache(targetfile,content)
    '/// Create Cahed Content ///
    Set Fs=createobject("scripting.filesystemobject")
    Set b=fs.createtextfile(targetfile,true)
    b.write content
    b.close
    set b=nothing
    set fs=nothing
    end function

    %>
    <%
    cachefolder=server.mappath("cache/")
    cachetimeframe="h"
    function getcache(cachetype,nocache)
    whatfile=cachetype
    strSeparator = "_"
    For Each var In Request.QueryString
    if lcase(var)<>"nocache" then parameters = parameters & "_" & var & "_" & replace(Request.QueryString(var),"/","-")
    next
    whatfile=whatfile & parameters
    whatfile=cachefolder&"\"&whatfile&".htm"
    resultfile=whatfile

    if nocache<>"" then
    Set Fs=createobject("scripting.filesystemobject")
    if fs.fileexists(whatfile) then
    Set objFile = fs.GetFile(whatfile)
    itsdate = objFile.DateLastModified
    set objFile=nothing
    if datediff(cachetimeframe,itsdate,now)<cachetime then
    Set a=fs.opentextfile(whatfile)
    content=a.readall
    a.close
    set a=nothing
    set fs=nothing
    resultfile=""
    response.write content
    end if
    end if
    set fs=nothing
    if resultfile="" then response.end
    end if
    end function

    function writecache(targetfile,content)
    '/// Create Cahed Content ///
    Set Fs=createobject("scripting.filesystemobject")
    Set b=fs.createtextfile(targetfile,true)
    b.write content
    b.close
    set b=nothing
    set fs=nothing
    end function

    %>

  9. #9
    E la chiamata di quella pagina dentro il src del javascript scrive qualcosa sulla pagina?

  10. #10
    Utente di HTML.it
    Registrato dal
    Jul 2004
    Messaggi
    89
    Si, scrive il titolo, il sommario e la data degli articoli a seconda delle impostazioni...
    non capisco come fa a funzionare...

    Poi se io devo scrivere del testo troppo lungo con documen.write non posso, infatti se scrivo questo codice mi da un'errore: document.write ('<% =" " & rds_ARTICOLI.fields("SOMMARIO")%>');
    mentre se cambio la voce sommario con il titolo o la data funziona...

    Comunque, sto impazzendo a tempestare la pagina di document.write, forse è meglio che uso l'include, l'unico problema è come faccio a passare il valore della variabile, magari creado una variabile di sessione?

    Grazie di tutto

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.