Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-08-2005, 05:35 AM   PM User | #1
dallen24
New Coder

 
Join Date: Jun 2002
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
dallen24 is an unknown quantity at this point
ASP as a preprosessor?

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
dallen24 is offline   Reply With Quote
Old 01-10-2005, 03:00 AM   PM User | #2
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
lastmod.asp: (include file)
Code:
<%
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)
Code:
<!--#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>"
...
%>
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:05 PM.


Advertisement
Log in to turn off these ads.