I'm on the private cloud and have a custom login page for our application. I'd like to use the optional parameter for error messages and display the messages to the user as a browser alert message. Is this possible? If so, can you point me in the right direct?
Thanks in advance for your help.
Hello,
You can get it by using a javascript code that gets the http parameter. Please see the code below found at http://stackoverflow.com/questions/827368/using-the-get-parameter-of-a-url-in-javascript
<script>
var param1var = getQueryVariable("param1");
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.split("=");
if (pair[0] == variable) {
return pair[1];
}
}
alert('Query Variable ' + variable + ' not found');
}
</script>
Just replace the param1 with the errMsg and then if the parameter has a value do an alert().
Thank you,
Gian
Hello,
You can get it by using a javascript code that gets the http parameter. Please see the code below found at http://stackoverflow.com/questions/827368/using-the-get-parameter-of-a-url-in-javascript
<script>
var param1var = getQueryVariable("param1");
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.split("=");
if (pair[0] == variable) {
return pair[1];
}
}
alert('Query Variable ' + variable + ' not found');
}
</script>
Just replace the param1 with the errMsg and then if the parameter has a value do an alert().
Thank you,
Gian
Do I just fire this function onload of the window then?
I had to tweak this code a little bit, but I was able to get this to work. Thanks for your help.
I have this code set in the window.onload function:
var myErrorMsg = '"";
if (str.indexOf("errMsg=") > 0)
{
var res = str.split("?");
for (var count in res)
{
var res2 = res[count].split("=");
if (res2.length > 1)
switch(res2[0])
{
case 'errMsg': myErrorMsg = res2[1];
myErrorMsg = myErrorMsg.replace(/\+/g,' ');break;
}
}
if (myErrorMsg !== "" && myErrorMsg !== null) {
alert(myErrorMsg);
}
}
It is much easier to extract URL parameters on server side assuming you're using technology like JSP or PHP.