Calling Common HTML code

Results 1 to 3 of 3

Thread: Calling Common HTML code

  1. #1
    4John Guest

    Default Calling Common HTML code

    On my website I have a JavaScript menu bar on every page. It was manually typed in HTML on every page also. The menu is exactly the same on all pages. The problem is that when I want to change a menu item, I have to change the JavaScript on every page. Can I use ASP and use some sort of substitution or "call" command that would autmatically reference an external file with the JavaScript HTML and plug it into the current page? This way I can make changes to the menu once and it&#039s reflected in all of the pages. Thanks...

  2. #2
    Join Date
    Dec 1969

    Default RE: Calling Common HTML code

    Yes, this is extremely easy to do. There must be about a dozen ways to do it with asp. How experienced are you with asp? I am not that great of a programmer, a much better designer.<BR><BR>Anyway, to begin, each asp page would include the script you want at the top like this:<BR><BR>&#060;!--#include virtual="/get_java.asp"--&#062;<BR><BR>Then at the point you want that java to appear, you write the name of the sub, like this<BR>&#060;%= javameister %&#062;<BR><BR>Then the file /get_java.asp might look like this:<BR>&#060;% sub javameister <BR>response.write "your javascript here"<BR>end sub<BR>%&#062;<BR>There are other ways to do it. One trouble that new asp guys run into is that response.write "what""ever"" " is messy and hard to understand, so if you need to include a double quote, it gets typed twice. <BR><BR>One way around this is for your javameister to open a seperate text file and just spit out the contents. I use this all the time. Here is what that would look like:<BR><BR>&#060;% sub javameister<BR><BR>thisisit = "c:wwwrootyourwebsitenamejavajava1.txt"<BR>&#039&# 060;!--"<BR><BR> Dim fs, banFile<BR> Set fs = Server.CreateObject("Scripting.FileSystemObject")< BR><BR> &#039Open banners.txt for reading<BR> Set banFile = fs.OpenTextFile(thisisit, 1)<BR><BR><BR> &#039Read the file:<BR> Dim mytext<BR> mytext = banFile.ReadAll<BR><BR> &#039 Close file<BR> banFile.Close<BR><BR><BR><BR>set fs = nothing<BR>set banfile = nothing<BR><BR><BR>response.write mytext<BR><BR>end sub<BR>%&#062;<BR><BR>Then you create a seperate file called java/java1.txt and it can be a simple file EXACTLY as it would appear on an HTML doc.<BR><BR>There is probably an easy way to do this right in your javameister sub, you should ask someone else!<BR><BR>Edward<BR><BR>

  3. #3
    yes. Guest

    Default RE: Calling Common HTML code

    use response.redirect("&#060;filename&#062;.asp")<BR>< BR>ie. response.redirect("../common/menubar.html") or<BR> response.redirect("../common/menubar.asp")<BR>which ever you prefer to make the menubar in..<BR>not sure if you can use a .js file.. I don&#039t do javascript..<BR>

Posting Permissions

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