Results 1 to 2 of 2

Thread: Loading different html files on my server into webpage based on clicked links

  1. #1
    kaijunexus is offline New Member: Posts Will Be Moderated
    Join Date
    Feb 2011
    Posts
    1

    Loading different html files on my server into webpage based on clicked links

    I have a website divided into two content areas. One is a list of links. In the other, I want to dynamically load an html or php file based on what link is pressed.

    I tried to do so using something like

    Code:
    <a href="#self" onclick="document.getElementById('content').innerHTML = '<!--#include file="file.shtml" -->';">link</a>
    <a href="#self" onclick="document.getElementById('content').innerHTML = '<!--#include file="file.php" -->';">link2</a>
    
    <div id='content'>
    </div>
    However, the files load onto the page before anything is clicked and do so within the link codes themselves. Should I not be using SSI for this? Please help?

  2. #2
    Join Date
    Mar 2010
    Location
    Ithaca, NY, USA
    Posts
    212
    SSI is basically obsolete, you should use PHP.

    On another note, you are not using it correctly. SSI is going to include that data before the page is sent, you can't access server data with a client-side script. You should do this using AJAX instead, libraries like jQuery will make it a breeze. You can change the onclick event to an AJAX call to fetch the data from the server and place it in the div, all without reloading the page.

Similar Threads

  1. Links that when clicked will ask the user to save
    By onempty in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 13 May 2009, 02:22 PM
  2. help with listing files from server
    By zipadee in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 19 May 2008, 07:32 AM
  3. webpage won't stop loading
    By webbon in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 29 Aug 2007, 11:10 AM

Posting Permissions

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