prudens Posted March 2, 2008 Share Posted March 2, 2008 echo "<a href=" . "javascript:history.back();" . ">Return</a>"; How come it doesn't work?? Quote Link to comment https://forums.phpfreaks.com/topic/94010-javascript-in-php/ Share on other sites More sharing options...
ignace Posted March 2, 2008 Share Posted March 2, 2008 javascript is a client-side language, php a server-side language use instead <?php if (array_key_exists('HTTP_REFERER', $_SERVER)) { header('Location: ' . $_SERVER['HTTP_REFERER']); } else { echo "<a href=\"#\" onclick=\"javascript:history.go(-1);\">click here to go back</a>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/94010-javascript-in-php/#findComment-481626 Share on other sites More sharing options...
fnairb Posted March 2, 2008 Share Posted March 2, 2008 You are losing your quotes around javascript:history.back();. The site won't let me save the example code for some reason so here is another example instead... echo '<a href="jscript:hist.back();">Return</a>'; Quote Link to comment https://forums.phpfreaks.com/topic/94010-javascript-in-php/#findComment-481627 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.