Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Passing basic information using JS only!

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #35544
    schart
    Participant

    This is not a question, more of a code show-off.
    This is really basic, it get’s the information like this (in the URL)
    http://www.domain.com/page.html?Information will be here, and it can include things like ! and ?

    Here is the code for saving the information behind the “?”, removing the “?” and fixing basic errors.
    Javascript code:

    var URLinfo = decodeURI(window.location.search.substring(1));

    decodeURI is for fixing “%20” for spaces and stuff like that. Also, the substring is to remove “?” in the start of the URL.

    Now (of course) you put this information anywhere like this:

    document.write(URLinfo)

    For instance, I use this for my sharing pop up. The way I did that was to make the link like this: http://www.domain.com/popuppage.html? + location.href
    and then I get the information on the sharing window and insert it in the sharing textbox. Really great :)

    #92257
    jamygolden
    Member

    Yeah that’s pretty cool. Have you seen this before?

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.