...

View Full Version : ASP as a preprosessor?



dallen24
01-08-2005, 06:35 AM
Hi. I was wondering if someone here could help. I have a simple javascript-based web site. On many sites, you see a little 'new' or 'updated' icon after recently modified hyperlinks. To simulate this feature, my html pages use code like <a href="home.htm">Home<span class="updated"></span></a>. When such a page loads, it has onload=js code that checks all the spans.getAttribute("href") references. With an array of page names/dates (from an external js file) if a page < 90 days and has a <span class='new'>, I do a spans.innerHTML = "<img src='new.gif'>".

I want to redo this logic. With my array of page names/dates I could just check all the <a href> on a page, appending the <img src> to each innerHTML with a href < 90 days old (I could do something with the arrays to let the code whether the href is 'new' or 'updated'). This would avoid having to add <span> code in the html page. Of course I still need to onload=js code, but I was thinking. Could I do an asp script as a preprocessor?

My web site is framed. If I call home.htm into frame main, is it possbile to execute an asp script that would read home.htm, add the little 'new' and 'updated' icons, then deliver the final home.htm page?

Any advice would be greatly appreciated...Dennis

glenngv
01-10-2005, 04:00 AM
lastmod.asp: (include file)


<%
Dim fileList
Set fileList = CreateObject("Scripting.Dictionary")
'add all the filenames with their corresponding modified date
fileList.Add "home.htm", "01/10/2005"
fileList.Add "page1.htm", "12/01/2004"
fileList.Add "page2.asp", "01/01/2005"
...

Function GetIcon(ByVal filename)
dim mod, img
mod = fileList.Item(filename)
if IsDate(mod) then
if DateDiff("d", mod, Date()) < 90 then
img = "<img src=""new.gif""" border=""0"" />
end if
end if
GetIcon = img
End Function
%>

main.asp: (that contains the links)


<!--#include file="lastmod.asp"-->
<%
response.write "<a href=""home.asp"">Home" & GetIcon("home.htm") & "</a>"
response.write "<a href=""page1.asp"">Page 1" & GetIcon("page1.htm") & "</a>"
response.write "<a href=""page2.asp"">Page 2" & GetIcon("page2.asp") & "</a>"
...
%>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum