L
L
ligisayan2020-10-13 16:25:30
JavaScript
ligisayan, 2020-10-13 16:25:30

How to pass state parameters from a domain to a subdomain in a link?

Hello!
There is a domain domen.com and a subdomain poddomen.domen.com

The domain has links leading to the subdomain, depending on clicking on which the subdomain must either open (open) or hide (close) the block

<p><a href="poddomen.domen.com" data-display="open">Ссылка 1</a></p>
<p><a href="poddomen.domen.com" data-display="close">Ссылка 2</a></p>


<div class="block">
Lorem ipsum
</div>

.block {
  display: none;
}
.block.open {
   display: block;
}


Question: how to transfer state parameters from a domain to a subdomain?

$('a').on('click', function () {
        e.preventDefault();
        location.href = $(this).getAttribute('href') + '?' +$(this).data('display');
    });

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex, 2020-10-13
@ligisayan

What's the problem then?

<p><a href="poddomen.domen.com?display=open">Ссылка 1</a></p>
<p><a href="poddomen.domen.com?display=close">Ссылка 2</a></p>

O
OCTAGRAM, 2020-10-29
@OCTAGRAM

I would just use cookies in the ".name.domain" domain. Such cookies, with a dot at the beginning, are valid for the entire domain with subdomains. Another option is to load a dynamic script from a subdomain in the domain. The script generator sees the contents of the session and generates a script that will show or hide the buttons.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question