View Full Version : Validate link for iframe
Hi,
I'm using an iframe to include one doc inside another. Trouble is, the name of the doc that gets loaded is a variable, and the document it refers to might not exist. Is there some way to validate that it's there prior to loading?:confused:
ACJavascript
07-23-2003, 12:55 AM
You mean somthing like
Click me to go to page 1
then the user clicks.. the script checks to make sure Page 1 is there and then loads it if it is?
If so I would use a server-side script to do that.
But what needs to be in the script to check if the page exists?
ACJavascript
07-23-2003, 04:18 PM
you could use perl like so
------
open(data,"directory/TheFile.html") || &NotThere;
@da(data);
close(data);
print "THIS PAGE IS THERE";
exit;
sub NotThere {
print "This page isn't here";
exit;
}
ReadMe.txt
07-24-2003, 09:36 PM
i would use PHP for this actually:
<?
echo (file_exists($_GET['page'])) ? "<script>location.replace('{$_GET['page']}')</script> : 'Page Does not Exist' ;
?>
save that as something like pagecheck.php then link to it like so:
pagecheck.php?page=home.htm where home.htm is the page you want.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.