joi, aprilie 26, 2007

Views Filtered by URL Parameter

These views are wonderful, however, when people bookmark them or stumble upon them without a URL parameter, they are nonsense.



So we use some javascript to let the user know that they have come into the page by mistake.




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];
}
}
alert('This page is for viewing a filtered report. Please return to this page with a valid filter.');
}
var IntRecordID = getQueryVariable("ID")


This will alert the user that they have come to the page without a Querystring variable and that they need to go back and rethink what they are trying to do.

Niciun comentariu:

Despre mine

Timi-Ostravia, Republic of Czedvia, Bulgaria
I make web applications. The tools I use are many and far between. I have been maining to learn Ruby and Python, and Perl. These tools are all like Lego to me. They can all be make to build things and have their strengths and weakest.