top of page

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. 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];    }  

 var imgSrc =”URL/Prefix”+gup(‘textvar’)+”_”+gup(‘anothertextvar’)+”.png”;    document.getElementById(“example).src = imgSrc;  

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 views0 comments

Recent Posts

See All

dplyr or base R

dplyr and tidyverse are convenient frameworks for data management and technical analytic programming. With more than 25 years of R experience, I have a tendency to analyze programmatic problems before


bottom of page