Results 1 to 8 of 8

Thread: External Pages fatching and display in one html page

  1. #1
    Join Date
    May 2009
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Exclamation External Pages fatching and display in one html page

    I have a very common question

    i have a website, where we can display my recent work in regular basis.

    now i would like to upload my daily work in individual html page in a particular folder and that will be display automatically in a html page (all in one page)
    Example:

    Day 1

    Projects details
    --------------------------
    Day 2

    Projects details
    --------------------------
    Day 2

    Projects details
    --------------------------

    its may be possible using ajax external page contains catching.

    but i need to develop the script

    waiting for your reply

    regards

  2. #2
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    If you are looking to create a page with links to uploaded HTML pages then you could do the following:

    Use the same filename prefix and append 1 to the prefix for each uploaded file, eg file1, file2, etc.

    Use a function that has a while loop. Then look for the filename plus the number.

    If the file exists then create and display the link.

    Increment the number.

    Loop back for the next file.

    In PHP you can use the PHP file_exists() function for this.

    If you do a search I'm certain you will functions in AJAX, ASP, etc.

    There are also functions that will list every file in a directory.

  3. The Following User Says Thank You to forum_amnesiac For This Useful Post:

    rtr.souvik (05-21-2009)

  4. #3
    Join Date
    May 2009
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanx a lot

    but i need the code

    can u help me out

  5. #4
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    What code are you using, PHP, Javascript, ASP, etc

  6. The Following User Says Thank You to forum_amnesiac For This Useful Post:

    rtr.souvik (05-22-2009)

  7. #5
    Join Date
    May 2009
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    I want to use java script for this

  8. #6
    Join Date
    May 2009
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    I am using javascript

  9. #7
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    Here is a simple page that will display all your work files, you should be able to adapt the display to fit your site.

    For this to work all the files must be in the same directory and have the same name prefix with a number suffix, eg workfile1, workfile2, workfile3, etc.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script>
    var rootpath="http://mydomain/mysubdirectory/";    // Put the details of where your files are
    
    function file_exists (url) {
        // http://kevin.vanzonneveld.net
        // +   original by: Enrique Gonzalez
        // +      input by: Jani Hartikainen
        // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
        // %        note 1: This function uses XmlHttpRequest and cannot retrieve resource from different domain.
        // %        note 1: Synchronous so may lock up browser, mainly here for study purposes. 
        // *     example 1: file_exists('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm');
        // *     returns 1: '123'
        
    	url=rootpath+url;
        var req = this.window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        if (!req) {throw new Error('XMLHttpRequest not supported');}
          
        // HEAD Results are usually shorter (faster) than GET
        req.open('HEAD', url, false);
        req.send(null);
        if (req.status == 200){
            return true;
        }
        
        return false;
    }
    
    function create_list(filenum1,filenum2){   // when the function is called put the range of numbers you want to appear in the column
    	var fileprefix="myfile";             // put the name prefix of your files
    	var ext="htm";                       // the file extension for your files
      	var optionCntr = 1;
    	for (x = filenum1; x <= filenum2; x++){
    		workfile=fileprefix+x+"."+ext;
    		fullfile=rootpath+workfile;
    		listfile=fileprefix+x;
    		if (file_exists(workfile)){
    		document.write('<a href="'+fullfile+'">'+ listfile +'</a><br>'); 
    		}
    	}
    }
    
    </script>
    
    </head>
    
    <body onload="create_list(7)">
    
    <form>
      <table border="0" width="100%">
        <tr>
          <td>
            </td>
            <td>
            <script>create_list(1,20)</script>
          	</td>
            <td>
            <script>create_list(21,40)</script>
          	</td>
            <td>
            <script>create_list(41,60)</script>
          	</td>
        </tr>
      </table>
    </form>
    
    
    
    </body>
    </html>

    The script checks for the existence of the file, if it does not exist it will not create a link.

  10. The Following User Says Thank You to forum_amnesiac For This Useful Post:

    rtr.souvik (05-22-2009)

  11. #8
    Join Date
    May 2009
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanx a lot
    i will try to impliment with this script,

    if any problem i will get back to you

    thanx again

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
  •