PHP和$(document.ready()冲突
我从工作中继承了一个网站,内置的php代码使$(document).ready()函数无法在代码中运行。当我删除它时,我点击了jquery代码,但我需要该php代码来运行该站点 PHPPHP和$(document.ready()冲突,php,jquery,Php,Jquery,我从工作中继承了一个网站,内置的php代码使$(document).ready()函数无法在代码中运行。当我删除它时,我点击了jquery代码,但我需要该php代码来运行该站点 PHP =(浮动)$html\u q){ $mime='application/xhtml+xml'; } } }否则{ $mime='application/xhtml+xml'; } }否则{ $mime='text/html'; } } 标题('Content-Type:'.$mime';charset=utf-8
=(浮动)$html\u q){
$mime='application/xhtml+xml';
}
}
}否则{
$mime='application/xhtml+xml';
}
}否则{
$mime='text/html';
}
}
标题('Content-Type:'.$mime';charset=utf-8');
标题('Vary:Accept');?>
下面几行是:
$(文档).ready(函数(){
console.log('doc is ready')
});
var _gaq=_gaq | |[];
_gaq.push([''设置帐户','UA-3725824-1']);
_gaq.push([''u trackPageview']);
(功能(){
var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;
ga.src=('https:'==document.location.protocol?'https://ssl' : 'http://www“)+”.google analytics.com/ga.js';
var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);
})();
我从未看到脚本中包含php代码的“doc已准备就绪”
我该怎么办?
谢谢 只需删除最后两行php
header()
行,然后添加
<代码>在您的模板中。这个问题是离题的,因为它要求我们成为网站管理员。谢谢!现在效果很好。
<?php if(strstr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'WDG_SiteValidator') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'W3C-checklink') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'Web-Sniffer') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'FeedValidator') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'Poodle predictor') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'Leknor.com gzip tester')) {
$mime = 'application/xhtml+xml';
} else {
if(stristr($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml')) {
if(preg_match("/application\/xhtml\+xml;q=([01]|0\.\d{1,3}|1\.0)/i", $_SERVER['HTTP_ACCEPT'], $matches)) {
$xhtml_q = $matches[1];
if(preg_match("/text\/html;q=q=([01]|0\.\d{1,3}|1\.0)/i", $_SERVER['HTTP_ACCEPT'], $matches)) {
$html_q = $matches[1];
if((float)$xhtml_q >= (float)$html_q) {
$mime = 'application/xhtml+xml';
}
}
} else {
$mime = 'application/xhtml+xml';
}
} else {
$mime = 'text/html';
}
}
header('Content-Type: ' . $mime . ';charset=utf-8');
header('Vary: Accept'); ?>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="keywords" content="keywords"/>
<script type='text/javascript' src = 'jquery-1.11.0.js'> </script>
<script type='text/javascript' src = 'jquery.fancybox.js'> </script>
<link rel='stylesheet' type='text/css' href='jquery.fancybox.css' />
<link rel='stylesheet' type='text/css' href='bicep2default.css'/>
<script type='text/javascript'>
$(document).ready(function() {
console.log('doc is ready')
});
</script>
<script type='text/javascript'>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3725824-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>