我打印 Javascript 函数以通过 PHP 脚本打开底部日志区域。这会使 Ajax、Excel 生成等非 dom 脚本崩溃。是否有像isDom()
PHP 那样的服务器端 dom 函数?
当前脚本:
if (System::$isDebug == 1 && self::$_registeredJsFunctions == false)
$this->registerJsFunctions();
registerJs函数:
protected function registerJsFunctions() {
self::$_registeredJsFunctions = true;
echo <<<EOD
<script type="text/javascript">
function printSystemLog(msg) {
if (!document.getElementById('ie-log')) {
$(document.body).append('<style type="text/css">'
+ '#ie-log { z-index:9999 !important; position:fixed; bottom:0; border-top: double 2px #939399; background:none #FDFDF0;width:100%;font-size:11px; font-family: "Courier New", Courier, monospace;overflow:hidden;}'
+ '#ie-log #debug-level { position: absolute; height: 25px; right:0px; top:0; width: auto; background:#ECF1EF; padding: 2px; color:#8B8378; z-index:9999;border: double 2px #939399;border-top: none;}'
+ '#ie-log #larea{ height:180px;padding:3px;overflow-y:scroll !important; overflow-x:hidden !important; }'
+ '#ie-log #lclose{ margin-left: 16px;}'
+ '#ie-log h3 { margin: 8px 5px; }'
+ '#ie-log #lclose a { padding: 3px; padding-left:17px; background:url(theme/standart/images/delete.png) left center no-repeat; color:inherit;}'
+ '#ie-log #lclose a:hover { background-color:#F1EDC2; text-decoration:none; color: #8B6914;}'
+ '#larea div.log-row { position:relative; margin: 3px 10px; border-bottom: solid thin #C4C49C; margin-left:20px; overflow: visible !important; }'
+ '#larea div.log-row span.arrright {position:absolute; height:16px; left: -20px; display:inline-block; width:16px; background: transparent url(theme/standart/images/arrow_right.png) left center no-repeat;} '
+ '</style>');
$(document.body).append('<div id="ie-log"><h3>Sistemin Anlık Log Görüntüsü</h3><div id="debug-level"><span>Seviye: <select onchange="logFilter(this.value)"><option value="">Hepsi</option><option value="EMERG">Emergency</option><option value="ALERT">Alert</option><option value="CRIT">Critical</option><option value="ERR">Error</option><option value="WARN">Warning</option><option value="NOTICE">Notice</option><option value="INFO">İnformation</option><option value="DEBUG">Debug</option></select></span><span id="lclose"><a href="#" onclick="closeLogArea();return false;" title="Çerez atar, bir dahakine açmaz">Kapat</a></span></div><div id="larea"></div></div>');
if (getCookie('TASARIMICI_LOG_SEVMEZ') == 1)
$('#ie-log').hide();
}
$('#larea').prepend('<div class="log-row"><span class="arrright"></span>'+msg + '</div>');
}
</script>
EOD;
}