setFragment (XSPUrl - JavaScript)

Sets the fragment identifier of the URL.

Defined in

XSPUrl (JavaScript)

Syntax

setFragment(fragment:string) : void
Parameters Description
fragment The new fragment.

Usage

The fragment identifier follows the # character after the URL proper and identifies a location in the URL content.

Example

This example sets the fragment identifier for a new XSPUrl object.
function p(stuff) {
	print("<<<" + stuff + ">>>");
}

var url : XSPUrl;

try {
	url = new XSPUrl("");
	url.setScheme("http");
	url.setHost("myhost.ibm.com");
	url.setPort(10038);
	url.setPath("/wps/PA_cow3tik/page1.xsp");
	url.setFragment("Preface");
	p(url.toString());

} catch(e) {
	p("Error = " + e);
}

Print output from the example is as follows:

<<<http://myhost.ibm.com:10038/wps/PA_cow3tik/page1.xsp#Preface>>>