Jump to content

Archived

This topic is now archived and is closed to further replies.

homer.favenir

javascript before redirect

Recommended Posts

hi,

can anyone please tell me how to execute javascript first before redirect?

 

i have a script here but it skips javascript and executes javascript.

<script language="JavaScript">
            alert ("Put your warning text here!")
            [removed]
        <?php 
            redirect('Front_cont/input_dir_ufpb_wp');
        ?>
</script>
i want to check if a file exist, 
if that file doesnt exist, it pops up an alert box and return to the 
input text page.

the problem is it skips the alert message and just redirect the page.

please advice.

thanks

Share this post


Link to post
Share on other sites

Chances are, the redirect() call is doing it's magic first.  What exactly does redirect do?  Send headers?  Headers come before content, so of course it would be executed first.

Share this post


Link to post
Share on other sites

i made it working now.

i just made a new page

when a file doesnt exist it will go to that page

and in that page is the javascript

<html>
<head>
<script type="text/javascript">
<!--
function delayer(){
    window.location = "<?php echo 'input_dir_ufpb_wp'; ?>"
}
//-->
</script>
</head>
<body onLoad="setTimeout('delayer()', 5000)">
<h2>Prepare to be redirected!</h2>
<p>This page is a time delay redirect, please update your bookmarks to our new 
location!</p>

</body>
</html>

 

thanks

 

 

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.