Frequently the developer wants to be able to get access to the url used to call a particular WaveMaker application. There are a number of standard Javascript global variables that provide this information (thanks to Jeff Martin for helping on this!).

  • window.location.href: this returns the complete url used to call the WaveMaker application
  • window.location.protocol: this returns a value like http: or https:
  • window.location.host: this returns a value like localhost:8094
  • window.location.pathname: this returns the application name with a forward slash before and after the name

Getting the Application Name

The application name returned by window.location.host is surrounded by forward slashes. To return just the application name, see the following code example:

var appName = window.location.pathname;
    // Split url - app name starts and ends with the slash character
    var results1 = new Array();   
    results1 = appName.split('/');
    alert('results = '+results1);
    this.text3.setDataValue(results1[1]);

Accessing URL Parameters

It is often useful to add a parameter to the end of the url, for example to pass in a particular starting data record for the application.

To access a parameter added to the end of the url, see the following code example:

// Get full url
    var appUrl= window.location.href;
    var results2 = new Array();
    // Split url - bookmark starts with the # character
    results2 = appUrl.split('#');
    // results[1] holds the parameter passed into the url
    if( results2[1] != null ) {
       this.text4.setDataValue(results2[1]);  
    }

      Share/Bookmark
© 2010 WaveMaker Software™ All Rights Reserved.