0
votes

I have some wierd but ETHICAL requirement. In our organization we have some tableau analytics dashboards. In Tableau web application paramaters required to filter the view can be pass through the querystring. E.g. I have date paramater defined as "StartDate" in tableau workbook, I can pass the value to this paramater using the querystring as www.xyz.com?StartDate="20/05/2016". Now my problem is, this tableau workbook URLs are embedded in another in-house web appplication but we don't have access to the code of that application so we can't pass the tableau parameter value from that web application. However we can request to embed the customized tableau URLs in that web application. But, for that we need to somehow send the date parameters through URL.

For this I decided to write inline JS function in the browser address bar itself and assign the date returned by the function to this "StartDate" paramater. Something like www.xyz.com?StartDate=javascript:(function () {var today = new Date(); var dd = today.getDate(); var mm = today.getMonth()+1; var yyyy = today.getFullYear(); if(dd<10){dd='0'+dd}; if(mm<10){mm='0'+mm}; var today = dd+'/'+mm+'/'+yyyy; return today;})();

But I am getting the querystring value in "StartDate" as the full function definition text and not the actual date that should be returned by the JS function on execution. In short, this function is not executing once it is placed after ? mark. I know this is sort of cross-site scripting but it is ethical in my case.

Please help me to execute this javascript function after the ? mark in address bar

Regards! Swad

1

1 Answers

0
votes

You want to run that in the address bar? Something like this then?

javascript:location.href="http://www.example.com?StartDate="+(function () {var today = new Date(); var dd = today.getDate(); var mm = today.getMonth()+1; var yyyy = today.getFullYear(); if(dd<10){dd='0'+dd}; if(mm<10){mm='0'+mm}; var today = dd+'/'+mm+'/'+yyyy; return today;})();