/    Sign up×
Community /Pin to ProfileBookmark

Checking if a document exists

I have a CBT that uses a javascript function to move forward or back through html pages with a numbering scheme; for example, 1.html, 2.html, 3.html….. How do I check to see if the html document exists before I try to display it?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@JPnycSep 14.2004 — Depends on the server OS.
Copy linkTweet thisAlerts:
@killiankauthorSep 15.2004 — I am running it on a local machine or the CD.
Copy linkTweet thisAlerts:
@Warren86Sep 15.2004 — Try this, just specify the path and file name:

<HTML>

<Head>

<Script Language=VBScript>

function checkExist()

set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists("ABC.txt") Then
MsgBox "There is an ABC.txt on the desktop..."
'you can put the name of a JS function here
Exit Function
End If
MsgBox "There is no ABC.txt on the desktop..."
'you can put the name of a JS function here

End Function

checkExist()


</Script>

</Head>

<Body>

<br><br>

<center>

<h4>Content of the page </h4>

</center>

</Body>

</HTML>
×

Success!

Help @killiank spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...