/**
* wrap javascript codes with a html-tag
* @author Wilson Zeng
*/
function js($script){
return '<script type="text/javascript">'."\n".$script."\n".'</script>'."\n";
}

/**
* wrap javascript codes with a html-tag & history back
* @author Wilson Zeng
* @param $message [optional] show alert() if is given
* @param $url [optional] the next step that will jump to if is given
* @author Wilson Zeng
*/
function jsBack($message = NULL, $url = NULL, $addslashes = TRUE){
$script = '';
if($message){
$script .= 'alert("'.str_replace('"', '\"', ($addslashes ? addslashes($message) : $message)).'");';
}
$script .= $url ? 'location.href="'.$url.'";' : 'history.back();';

echo js($script);
exit(0);
}
posted on 2012-01-17 13:57  重生  阅读(158)  评论(0编辑  收藏  举报