Magento上CDN后js出错

Magento 做了cdn后,后台编辑器的文件上传功能出问题了

经测试,方法有二:


1.js允许跨域

js/tiny_mce/tiny_mce_popup.js

头部加入

document.domain = 'domain.com';

document.domain = window.location.hostname.split('.').splice(-2).join('.')

app/design/adminhtml/default/default/template/page/head.phtml

调用tinymce的js之前(49行),加入

<script>document.domain = 'domain.com'; </script>

<script>document.domain = '<?php echo implode('.',array_slice(explode('.',str_replace('/js/','',$this->getJsUrl())),1,2));?>'; </script>


2.后台代码修改回原路径(改动量最少)

app/design/adminhtml/default/default/template/page/head.phtml

51行:

<script type="text/javascript" src="<?php echo $this->getJsUrl() ?>tiny_mce/tiny_mce.js"></script>

替换成

<script type="text/javascript" src="<?php echo str_replace('/index.php','',$this->getBaseUrl()) ?>js/tiny_mce/tiny_mce.js"></script>



以下文件也要改flash文件上传跨域

app/design/adminhtml/default/default/template/cms/browser/content/uploader.phtml


**原创文章未经同意请勿转载**