Home > Software engineering >  How to open page with different style depending on which button was clicked by the user?
How to open page with different style depending on which button was clicked by the user?

Time:11-26

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)

CodePudding user response:

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

CodePudding user response:

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.

  • Related