URL params js issue

Hello again :slight_smile:

I’m working on my first js real project. I’m facing a “weird” issue …

everytime i click on the clock icon or increment a round it removes the param from the url … and nothing else happens.

http://inkroyable.ch/time2roll

Click in 3:00 for instance…

Any ideas ?

Thanks in advance. :sweat_smile:

Maybe I’m misunderstanding. In your html you have something like:

                    <button id="homeButton" class="active" onclick="window.open('index.html', '_self');">
                        <i class="far fa-clock"></i>
                    </button>

Isn’t that telling that button (the clock) to go back to the index.html? You are giving it a new url. And isn’t your target url time.html anyway? I don’t know, it’s hard to see without your code.

1 Like

Yes it is telling to go back to index.html … but this isn’t working … it is just removing the param from the url … because if it returns to index.html … the user will choose again the time to pass on the param.

http://www.inkroyable.ch/time2roll/js/functions.js

The js code.

First of all, as I understand window.open(), it creates a new window, not redirect the current window.

Could you try something like:

window.location.href = "index.html";

If that doesn’t work, try specifying the complete URL. If that doesn’t work, try both for time.html.

Another option is also to use an anchor tag and just style it like a button.

1 Like

Thanks for the fast reply… this was the way i have done before … and i’ve changed it because it doesn’t work as well.

But the more strange is when we increment a round … it change the url params as well.

Weird :confused:

Again, I think you might consider and anchor tag which seems more logical for what you’re trying to do.

But also, I’m not clear on why your are using params in the first place. Are you righting a backend for this? That is usually what url params are for.

Since it is using 2 .html and it will be used as mobile app as well i thought to use the params to define the match time instead of one page for each match time.

If i use i will not be able to disabled the increment of decrement rounds …

For the clock … i’ve changed as you adviced and it WORKED :sunny: :blush:

For the < 1 > ( increment & decrement rounds ) what do you think would be better ? ? ? make it not visible instead of disabled ?

http://inkroyable.ch/time2roll <-- updated .

Thanks a million :slight_smile:

Right, but I’m thinking you’re misunderstanding what url params are for. They are not to communicate to the user or store information, they are for sending information to the server. You can use them for navigation if you set up a corresponding folder structure in the public directory or if you set up route logic on your server or some kind of routing emulator in an SPA. Things like params can also be sent to help the server logic figure out what do do. You should not be putting parameters unless you are defining what to do with them in the server code. And, it makes sense that params are being removed. You are trying to change the navigation by assigning the url. The params are part of the url.

I think you need to rethink what you are trying to do. All of what you are suggesting can be done without messing with the url. If you want some notification to the user at the top there, you can use the browser pane title. That’s what it’s for. It’s not what the url is for.

Hummm , thanks again for the wise advices. :ok_hand: