Search

URL parameters

I have used URL parameters a few times for survey reporting. Elements which require custom markup are often more easily defined as separate webpages, these can then be embedded as iframes and tested thoroughly on their own.

Example: Custom image on webpage

We use two  URL parameters to form the source of a custom image on a webpage. http://www.exampleurl.com?textvar=1&anothertextvar=ext A simple javascript in the header makes parsing of variables possible:  function gup( name )    {     name = name.replace(/[\[]/,”\\\[“).replace(/[\]]/,”\\\]”);     var regexS = “[\\?&]”+name+”=([^&#]*)”;     var regex = new RegExp( regexS );     var results = regex.exec( window.location.href );     if( results == null )      return “”;     else      return results[1];    }  

Embed in iframe

It is rather straight forward to embed the graphics in an iframe and using the id tag.

Just add a script by the end of the page or following the iframe tag set.

 var textvar=1;    var anothertextvar=”ext”;    document.getElementById(“test”).src = “URL/Example.html?textvar=”+textvar+”&anothertextvar=”+anothertextvar;  

0 views

Recent Posts

See All

©2020 by Danish Institute for Data Science. Proudly created with Wix.com