PDA

View Full Version : open file possible



hayseed
12-21-2005, 02:42 PM
is it even possible to open a file using javascript on something other than web related targets .... in other words open something where the target is on my machines.... C:\Documents and Settings\hayseed\Desktop\ post\600 part1.doc ..... or C:\Documents and Settings\hayseed\Desktop\ post\600 part.jpg

have no trouble using scripts till i target them to my local files.... have spent unbelievable amount of time google searching and have yet to get it right....... thanks for your thoughts....h

Twey
12-21-2005, 02:55 PM
Locally or remotely? Are you going to be uploading this script to a server?

hayseed
12-21-2005, 04:25 PM
thanks twey.... locally... if its even possible in the first place , the script might be part of a web page that you could download .... so many could use it....

of course you would have to have the same named targets for it to work....

i'm just trying to step through a folders contents, placed in an array in a timed manner.... javascript does that easy with web based items.... if it can open targets in a new browser, a program, it would seem possible to open a jpg, doc, pdf, or such here locally in the proper associated program....

i have a simple javascript timer and the array is easy enough, its the open part that hanging me up.....

and i have spent many hours google searching javascript for any clue that it can be done..... i can explain it further if need be...... thanks for your time......h

Twey
12-21-2005, 04:44 PM
You can just window.open('file://C/Documents%20and%20Settings/hayseed/file.odt').

hayseed
12-22-2005, 04:08 AM
thanks for the suggestion twey.... it gets me a lot closer.....h

hayseed
12-22-2005, 04:51 PM
its possible i'm makin matters worse... this simple timer script works perfect on web based objects.... does anybody see an obvious error when using my local files... any pointers appreciated, not asking for anyone to complete it .....thanks.....h

<script language="JavaScript">
// counter and name funtion

var i = 0;
function flipbook()
{


// set up list of files
//.mws is just my file ext used here


chart = new Array()

chart[0]="C:\desktop\Data\30\MSS\c1.mws"

chart[1]="C:\desktop\Data\30\MSS\c10.mws"

// load files
document.chart[0].mws=chart[i]

// increment counter
i=i+1;

// when at the end, start again
if(i==101) { i=0; }

// i believe part of my problem lies in the <img src="chart1.mws" name="chart"> part below
// twey's suggestion window.open('file://C/Documents%20and%20Settings/hayseed/file.odt').
}
</script>
</head>


<body onLoad="javascript:setInterval('flipbook()', 1000)">

<img src="chart1.mws" name="chart">


</body>

hayseed
12-22-2005, 06:56 PM
as a comparrison , this stripped down version works everytime.... but ony with web based targets.... surely there must be a way to subsitute my local files....h

==================
<script language="JavaScript">
// simple timer
var i = 0;
function hayseed()
{
// add more if need be
slidesArray = new Array()

slidesArray[0]="http://sprott.physics.wisc.edu/fractals/collect/1995/002.JPG"
slidesArray[1]="http://sprott.physics.wisc.edu/fractals/collect/1995/003.JPG"
slidesArray[2]="http://sprott.physics.wisc.edu/fractals/collect/1995/010.JPG"





// load image
document.images[0].src=slidesArray[i]

// increment counter
i=i+1;

// when at the end, start again
if(i==101) { i=0; }
}
</script>
</head>
<body onLoad="javascript:setInterval('hayseed()',5000);">
<img src="http://sprott.physics.wisc.edu/fractals/collect/1995/1.GIF" name="image">