Передача значения
Собственно есть код на первой странице:
function transmit() {
var imgSrc = table.getElementsByClassName('active_thumb')[1].getElementsByTagName('img')[2].getAttribute('src');
window.name = input.value+'*'+imgSrc;
window.location ='http://parapapa.ru/index1.html';
}
И код на второй:
var arr = window.name.split('*');
document.getElementById('id_buy_item').value = arr[0];
document.getElementById('preview').getElementsByTagName('img')[1].setAttribute('src', arr[2]);
window.name='';
Смысл в том, что мне с одной страницы на другую требуется передать текст и изображение, но в конечном счете получаю undefened. Поможите :) |
Aftal1ck,
Как только ты переходишь по ссылке, объект window создается заново. Если хочешь передать параметры между страницами, то можно через query string. 'http://parapapa.ru/index1.html?param1=value1¶m2=value2'; |
Это уже другой лес, сделал своим способом:
На первой странице:
<script type="text/javascript">
блаблабла....
function transmit() {
var imgSrc = table.getElementsByClassName('active_thumb')[0].getElementsByTagName('img')[0].getAttribute('src');
window.name = imgSrc;
window.location ='http://parapapa.ru/forest/message.html';
}
На второй странице:
<script type="text/javascript">
var arr = window.name;
document.getElementById('id_buy_item').value = arr;
document.getElementById('preview').getElementsByTagName('img')[0].setAttribute('src', 'http://parapapa.ru/images/xxl/'+arr);
window.name='';
</script>
|
| Часовой пояс GMT +3, время: 19:40. |