1

I realise a lot of similar questions exist, but none of them seem to fit my needs.

Context

Essentially I have a button that when clicked:

  • converts text to morse code
  • then removes the button and replaces it with three social buttons.

Problem

Essentially, whenever that button is clicked I want:

  • the browser to add ?123456 (random number) to the end of the URL to allow that to be shared on social networks.

Any ideas? Thanks!

scott_lotus
  • 3,171
  • 22
  • 51
  • 69
Joe
  • 51
  • 4
  • Here's a jsfiddle: https://jsfiddle.net/LLe0shk5/ – Joe Jan 04 '16 at 21:22
  • 5
    If you're doing this server-side, you'll want to issue a 302 redirect to the desired URL. If you're doing it client-side, have a look at [History.pushState()](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState) (which will allow you to insert a URL into the browser's history without causing a page reload). If you're doing this to prevent Facebook, etc. from caching the page, there are probably better ways. – greenie2600 Jan 04 '16 at 21:24
  • I've done that before with hashes. http://stackoverflow.com/questions/13986231/jquery-ajax-adding-hash-in-the-url Then you can parse that hash later with jQuery after someone visits the link. Although, I like the redirect idea above better. – Tony DeStefano Jan 04 '16 at 21:32
  • http://stackoverflow.com/questions/10953792/change-url-in-browser-address-bar-without-reload-existing-page – Tasos Jan 04 '16 at 21:37
  • What's the actual purpose of the number? – Mic Jan 04 '16 at 21:46
  • To create a unique URL. Needs to be in the format 'http://example.com/?123456' – Joe Jan 05 '16 at 09:45

0 Answers0