SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Birmingham, AL
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I include an html file in javascript?

    I'm trying to use this a Tree Menu (from CoolDev). I am trying to put an include statement in the javascript so I can include an html file, but have had no success so far.

    Here's an example line of the code:
    Code:
     ['Images', null, null,
      ['Simple', null, null,
       ['</a><img src="img/test1.jpg" width="200" height="100" alt="Test image 200x100"><a>', null, null]
      ],
    I've tried the following ways, but still get errors.

    Code:
     ['Images', null, null, 
    	  ['Simple', null, null, 
    		 ['</a><!--#include file='dir/filename.htm'--><a>', null, null]
     ],
    Code:
     ['Images', null, null, 
    	  ['Simple', null, null, 
    		 ['</a><!--#include virtual="menu.html" --><a>', null, null]
     ],
    I'm sure I'm just doing this wrong, any tips on how to include an html file in javascript?

  2. #2
    Vermicious Knid moncur's Avatar
    Join Date
    May 2003
    Location
    Salt Lake City, UT
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is no way to include an HTML file in JavaScript. It looks like you're trying to use SSI (Server Side Includes) to include the file.

    I don't see anything particularly wrong with your SSI syntax, but there are a number of things that could be wrong on the server to prevent them from executing. What errors do you get?

  3. #3
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    A good method is to introduce the new HTML into an iFrame. You can also read the data that the iFrame contains so long as its from the same site
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


Bookmarks

Posting Permissions

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