
22.08.2009, 13:48
|
|
Новичок
Регистрация: 08.10.2007
Сообщений: 22
Провел на форуме: 251502
Репутация:
3
|
|
оно вставляет в хтмл файл свои данные
именно
почему ж нельзя вставить напрямую в JS?
можно, но почему-то когда я пишу именно так, как вы предлагаете, не происходит никакой реакции.
Возьмем файл 1.cfg следующего содержания:
// This file is overwritten whenever you change your user settings in the game.
// Add custom configurations to the file "userconfig.cfg".
unbindall
bind "TAB" "+showscores"
bind "ENTER" "+attack"
bind "ESCAPE" "cancelselect"
bind "SPACE" "+jump"
bind "'" "+moveup"
bind "*" "amx_votemapmenu"
bind "+" "hlg_menu 895623"
bind "," "buyammo1"
bind "-" "amx_statscfgmenu"
bind "." "buyammo2"
bind "/" "+movedown"
bind "0" "slot10"
bind "1" "slot1"
bind "2" "slot2"
bind "3" "slot3"
bind "4" "slot4"
bind "5" "slot5"
bind "6" "slot6"
bind "7" "slot7"
bind "8" "slot8"
bind "9" "slot9"
Вставка {<<{W.moddir}\1.cfg} в ваш скрипт равносильна, что я сделаю так:
Код:
<textarea id="text" rows="25" cols="100" readonly></textarea>
<script language="javascript">
var text = '// This file is overwritten whenever you change your user settings in the game.
// Add custom configurations to the file "userconfig.cfg".
unbindall
bind "TAB" "+showscores"
bind "ENTER" "+attack"
bind "ESCAPE" "cancelselect"
bind "SPACE" "+jump"
bind "'" "+moveup"
bind "*" "amx_votemapmenu"
bind "+" "hlg_menu 895623"
bind "," "buyammo1"
bind "-" "amx_statscfgmenu"
bind "." "buyammo2"
bind "/" "+movedown"
bind "0" "slot10"
bind "1" "slot1"
bind "2" "slot2"
bind "3" "slot3"
bind "4" "slot4"
bind "5" "slot5"
bind "6" "slot6"
bind "7" "slot7"
bind "8" "slot8"
bind "9" "slot9"';
var elem = document.getElementById('text');
var length = 3; //3 строчки с конца
var pos1 = text.length;
var pos2 = text.length;
for (i = 0; i < length; i++)
\{
pos1 = text.lastIndexOf("\r\n", pos2);
if (pos1 < 0)
\{
elem.value = text.substring(0, pos2 + 2) + "\r\n" + elem.value;
break;
} else \{
elem.value = text.substring(pos1 + 2, pos2 + 2) + "\r\n" + elem.value;
}
pos1 -= 2;
pos2 = pos1;
}
</script>
А если я делаю так, то опять же ничего не происходит
|
|
|