javascript - Check if path exists else display error -
i have js function creates url appropriate pdf file based on option user has chosen.
i have of function sorted out i'd know how check if path pdf file exists in case users version hasn't got pdf's downloaded.
for i'll need alert(); example see needs done here's current code
function pdfselected(selected) { keynumberstr = keynumber.tostring(); pdfdisplay = "pdf/key" + keynumberstr + selected + ".pdf"; if (selected === "summary" || registered) { //insert code check file existence window.location.href = pdfdisplay; } else { window.alert("this option available registered users"); }
}
i've added comment need check whether file exists or not. if exists, go straight pdf. else display alert tell user file missing.
hope can little help, thank in advance , sorry simple question (noob @ js , don't know how incorporate other answers cater problem)
Comments
Post a Comment