Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  • Thread Tools
  • Rate This Thread
  1. #1
    New to the CF scene
    Join Date
    May 2016
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Call different query strings in a single url

    Hi there,

    I have a mission to build a page with a html5 video, but I need to call different videos according to the query string of the video instead of creating different html pages.

    For example, if I place a link in a newsletter like mydomain.com/?id=10505, it will open the html page with the video for that query string.

    I played around with codepen and if you guys could help me with this charade it will be great.

    http://codepen.io/fernandofas/pen/MyxVoQ


    Thanks in advance.

    Fernando Fas

  2. #2
    Regular Coder
    Join Date
    Feb 2016
    Posts
    128
    Thanks
    0
    Thanked 32 Times in 32 Posts
    Should be easy to do. Is the ID in the query string the same ID that has to be added to the video's URL?
    Could you provide two or three valid IDs to enable for testing?

  3. #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    8,131
    Thanks
    3
    Thanked 814 Times in 803 Posts
    This is the post a JavaScript to share forum.

    So where is the script you are trying to share with everyone?
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  4. #4
    Regular Coder
    Join Date
    Feb 2016
    Posts
    128
    Thanks
    0
    Thanked 32 Times in 32 Posts
    TO hit the wrong forum.

    Hallo Fernandofas,
    try this Javascript:
    Code:
                $(document).ready(function () {
                    querystring = window.location.href.match(/.*(\?.*)/);
                    if (querystring) var theVid = 'http://techslides.com/demos/sample-videos/small.mp4' + querystring[1];
                    else var theVid = 'http://techslides.com/demos/sample-videos/small.mp4?id=10506';
    
                    var player = document.getElementById('videoPlayer');
                    //var mp4Vid = document.getElementById('mp4Source');
    
                    player.pause();
    
                    // Now simply set the 'src' attribute of the mp4Vid variable!!!!
                    //$("#mp4Source").attr('src', theVid);
                    player.src = theVid;
                    player.load();
                    //player.show();
                    player.play();
                });
    Last edited by Sempervivum; 05-11-2016 at 08:22 PM.

  5. #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    8,131
    Thanks
    3
    Thanked 814 Times in 803 Posts
    With JavaScript correctly placed at the bottom of the page the ready call is not required as the page is ready before the script starts to run.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  6. #6
    New to the CF scene
    Join Date
    May 2016
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi felgall,

    The codes are in the link on the original post.

    Cheers.

  7. #7
    New to the CF scene
    Join Date
    May 2016
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Sempervivum,

    Thanks for your kindly reply.

    Your codes works and I'm very happy with the result.

    You are a star.

    Kind regards,

    Fernando Fas


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •