因为用到www和没www同种域名同时访问,所以,存在js跨域问题,
解决方法如下
解决js跨域问题:
注意下面代码不能直接放到html中,因为tipask的模板解释script,导致页面出错;
所以只能使用js调用方式js_reset_domain(js_path)
qidizi.js 代码如下
function js_reset_domain(js_path)
{//解决跨域问题,替换成当前域
js_path = js_path.replace(/^ *http/:[^//]+/i,"http://" + location.hostname);
js_path = '<script type="text/javascript" ' + ' src="' + js_path;
js_path = js_path + '" ' + '></script' + '>';
document.writeln( js_path );
}
调用方式:
<script type="text/javascript" src="{SITE_URL}js/qidizi.js"></script>
<script type="text/javascript">
js_reset_domain("{SITE_URL}js/jquery.js");//主要是这个跨域时出错
js_reset_domain("{SITE_URL}js/dialog.js");
js_reset_domain("{SITE_URL}js/common.js");
</script>