Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    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>"
    ...
    %>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •