IEのみ:<script src=”hogehoge.js”></script>を書き換える方法

window.onload = update;
function update() {
var script = document.getElementsByTagName(“script”);

for (var i = 0, len = script.length; i < len; i++) {
var uri = script[i].src;
if (!uri.match(/hogedir\/hogehoge\.js/)) continue;
script[i].outerHTML=myJSONObject.text;
}

}

など。
outerHTMLはIEのみ。
多くのブラウザ対応させたいなら、DIVタグ内に挿入などの場合は、innerHTMLで行ったほうがよい。

Smarty用テンプレートがShiftJISでも使えるようにする。

//Smarty用テンプレートがShiftJISでも使えるようにする。
$smarty->register_prefilter(“convert_encoding_to_eucjp”);
$smarty->register_postfilter(“convert_encoding_to_sjis”);

//Smarty用SJIS文字化け対策
function convert_encoding_to_eucjp($template_source, &$smart) {
if (function_exists(“mb_convert_encoding”)) {

$enc = mb_detect_encoding($template_source, “auto”);
if ($enc != “EUC-JP”) {
return mb_convert_encoding($template_source, “EUC-JP”, $enc);
}

}
return $template_source;
}

function convert_encoding_to_sjis($template_source, &$smart) {
if (function_exists(“mb_convert_encoding”)) {
return mb_convert_encoding($template_source, “SJIS”, “EUC-JP”);
}
return $template_source;
}