Skip to main content
Inspiring
October 25, 2019
Question

How to get URL Parameters into HTML Canvas?

  • October 25, 2019
  • 2 replies
  • 981 views

Here's a javascript function that reads the URL parameters and makes them usable for javascript.  How can I adapt this for use inside a HMTL Canvas in Adobe Animate?  I have tried unsuccessfully.

 

function GetURLParameter(sParam)
{
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&');
    for (var i = 0; i < sURLVariables.length; i++) 
    {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam) 
        {
            return sParameterName[1];
        }
    }
}​

// Retrieve Parameters and set Variables
var lab = GetURLParameter('lab');
var sec = GetURLParameter('sec');

 

 

Help much appreciated. I'm new to Animate, and have been searching for the solution.

Cheers,

Geoff

 

This topic has been closed for replies.

2 replies

Legend
October 25, 2019

"I have tried unsuccessfully" is a completely useless statement for troubleshooting. Have you checked the browser's dev console for errors? Is the function even running? Is it crashing? Is it returning the wrong values? Unexpected values? Any values at all?

 

 

Inspiring
October 25, 2019

Hi Geoff

 

I've attached an FLA that shows how your code can be used to populate a dynamic text box with URL parameters in Animate HTML5.

 

Hope it helps!  Let me know if you have any questions.

 

FLA in zip file.