Log in

View Full Version : External Pages fatching and display in one html page



rtr.souvik
05-21-2009, 04:39 AM
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

forum_amnesiac
05-21-2009, 07:20 AM
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.

rtr.souvik
05-21-2009, 11:34 AM
Thanx a lot

but i need the code

can u help me out

forum_amnesiac
05-22-2009, 07:10 AM
What code are you using, PHP, Javascript, ASP, etc

rtr.souvik
05-22-2009, 07:43 AM
I want to use java script for this

rtr.souvik
05-22-2009, 12:12 PM
I am using javascript

forum_amnesiac
05-22-2009, 03:55 PM
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.


<!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.

rtr.souvik
05-22-2009, 07:07 PM
Thanx a lot
i will try to impliment with this script,

if any problem i will get back to you

thanx again