Any Javascript experts here?

I'm trying to grab a variable from the URL and then use that variable within Squiffy.

Grabbing the variable from the URL is actually quite easy. Say my URL is http://example.com/story.php?name=john

I can use the following code in my main HTML document to grab the name:

<script>
function getQueryVariable(variable)
{
   var query = window.location.search.substring(1);
   var vars = query.split("&");
   for (var i=0;i<vars.length;i++) {
           var pair = vars[i].split("=");
           if(pair[0] == variable){return pair[1];}
   }
   return(false);
}

var myurldata = getQueryVariable("name");

 </script>

My JS name variable now = john.

However. I'm struggling to actually use this within Squiffy. I tried to actually run the code within Squiffy, rather than locating it in my HTML document, but it doesn't seem to work.

Any advice?


Silly me, I forgot about the way JS declares global and local variables. All is fixed now.


This topic is now closed. Topics are closed after 180 days of inactivity.

Support

Forums