Skip to content

Can't open page with custom url to load correct api data #138809

Closed Answered by jgschmitz
unviere asked this question in Programming Help
Discussion options

You must be logged in to vote

Hi Unviere,

Instead of using query parameters (e.g., ?gameName=...), you can use fragment identifiers (#gameName), which GitHub Pages handles better because the URL doesn't change on the server side. Maybe try something like this:

JavaScript for redirecting to game.html:

gameClone.addEventListener('click', () => {
  console.log('Game clicked:', game.name);

  // Use fragment identifier instead of query parameters
  const customPageUrl = `https://unviere.github.io/Unviere/games/game.html#${encodeURIComponent(game.name)}`;

  // Navigate to the constructed URL
  window.location.href = customPageUrl;
});

In your game.html page: Change how you retrieve the game name from the URL:

document.ad…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by unviere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Programming Help Programming languages, open source, and software development.
2 participants