0

I want to make two buttons, which will open (depending which is clicked) new page but with different style.

I added eventListener to button and I used window.open, then I want (if it's posible) to somehow call function after the new page is loaded to change style of some elements.

I want to have result similar to two identical htmls but with different function calls from script, but in more dynamic form(so without copypasting htmls)

Pawlinho
  • 69
  • 1
  • 7
  • Add code to said question. [How to ask](https://stackoverflow.com/help/how-to-ask) – zer00ne Nov 25 '21 at 15:34
  • Use variation of a search parameter or hash in the url and check what is in the url in the new page then add a class to body accordingly and use css rules for that class – charlietfl Nov 25 '21 at 15:36

2 Answers2

2

The first idea that comes to my mind is to pass some GET parameters to indicate whether to apply one of your 2 styles

but if you maybe provide code examples or more details about your problems (code snippets/framework used if any )it may help more for addressing your exact problem and solving it quicker

How to retrieve GET parameters from JavaScript ,This may help if you choose to proceed with my solution

1

An alternative is to use localStorage and save some piece of data about the style and then on the other window load event you can retrieve and apply it's data where you think it is needed.

Lucas Gabriel
  • 363
  • 3
  • 9