- URL
- Enable navigation for last Breadcrumb item
- Open URL in new page or tab
Contact Support
Navigation in EJ2 JavaScript Breadcrumb control
2 May 202314 minutes to read
Breadcrumb navigations support you to provide relative or absolute URL for breadcrumb items, enable navigation for the last item of the Breadcrumb component, and open URL in a new tab or new page.
URL
In the Breadcrumb component, the item represents the URL. The breadcrumb items can be provided with either relative or absolute URL.
Relative URL
The url
property of the items contains a portion of the full path which is based on its relation to the current path where it is linked. In the following example, the items represent only the relative URL path.
ej.base.enableRipple(true);
var items = [
{
text: "Home",
url: "../"
},
{
text: "Getting",
url: "./breadcrumb/getting-started"
},
{
text: "Icons",
url: "./breadcrumb/icons"
},
{
text: "Navigation",
url: "./breadcrumb/navigation"
},
{
text: "Overflow",
url: "./breadcrumb/overflow"
}
];
new ej.navigations.Breadcrumb({
items: items,
enableNavigation: false
}, '#breadcrumb');
<!DOCTYPE html><html lang="en"><head>
<title>Essential JS 2</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="Essential JS 2">
<meta name="author" content="Syncfusion">
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-navigations/styles/material.css" rel="stylesheet">
<!--style reference from app-->
<link href="styles.css" rel="stylesheet">
<!--system js reference and configuration-->
<script src="https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div class="control-section">
<nav id="breadcrumb"></nav>
</div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Absolute URL
The url
property of the items contains the full path or entire address of the page. In the following example, the items represent absolute URL.
ej.base.enableRipple(true);
var items = [
{
text: "Home",
url: "https://ej2.syncfusion.com/documentation/introduction/"
},
{
text: "Getting",
url: "https://ej2.syncfusion.com/documentation/breadcrumb/getting-started"
},
{
text: "Icons",
url: "https://ej2.syncfusion.com/documentation/breadcrumb/icons"
},
{
text: "Navigation",
url: "https://ej2.syncfusion.com/documentation/breadcrumb/navigation"
},
{
text: "Overflow",
url: "https://ej2.syncfusion.com/documentation/breadcrumb/overflow"
}
];
new ej.navigations.Breadcrumb({
items: items,
enableNavigation: false
}, '#breadcrumb');
<!DOCTYPE html><html lang="en"><head>
<title>Essential JS 2</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="Essential JS 2">
<meta name="author" content="Syncfusion">
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-navigations/styles/material.css" rel="stylesheet">
<!--style reference from app-->
<link href="styles.css" rel="stylesheet">
<!--system js reference and configuration-->
<script src="https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div class="control-section">
<nav id="breadcrumb"></nav>
</div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Enable navigation for last Breadcrumb item
Breadcrumb enables the navigation for the last item by setting the enableActiveItemNavigation
property to true. In the following example, the last item of the Breadcrumb
was enabled.
ej.base.enableRipple(true);
var items = [
{
text: "Home",
url: "https://ej2.syncfusion.com/documentation/introduction/"
},
{
text: "Getting",
url: "https://ej2.syncfusion.com/documentation/breadcrumb/getting-started"
},
{
text: "Icons",
url: "https://ej2.syncfusion.com/documentation/breadcrumb/icons"
},
{
text: "Navigation",
url: "https://ej2.syncfusion.com/documentation/breadcrumb/navigation"
},
{
text: "Overflow",
url: "https://ej2.syncfusion.com/documentation/breadcrumb/overflow"
}
];
new ej.navigations.Breadcrumb({
items: items,
enableNavigation: false,
enableActiveItemNavigation: true
}, '#breadcrumb');
<!DOCTYPE html><html lang="en"><head>
<title>Essential JS 2</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="Essential JS 2">
<meta name="author" content="Syncfusion">
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-navigations/styles/material.css" rel="stylesheet">
<!--style reference from app-->
<link href="styles.css" rel="stylesheet">
<!--system js reference and configuration-->
<script src="https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div class="control-section">
<nav id="breadcrumb"></nav>
</div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Open URL in new page or tab
To open the url provided in the items in a new page or tab, set the target property of the anchor element for the required item to “_blank” in the beforeItemRender
event of Breadcrumb component. In the following example, the target property of anchor element for the item was set to “_blank” by using the beforeItemRender
event which locates to the path in the new tab.
ej.base.enableRipple(true);
var items = [
{
text: "Home",
url: "https://ej2.syncfusion.com/documentation/introduction/"
},
{
text: "Getting",
url: "https://ej2.syncfusion.com/documentation/breadcrumb/getting-started"
},
{
text: "Icons",
url: "https://ej2.syncfusion.com/documentation/breadcrumb/icons"
},
{
text: "Navigation",
url: "https://ej2.syncfusion.com/documentation/breadcrumb/navigation"
},
{
text: "Overflow",
url: "https://ej2.syncfusion.com/documentation/breadcrumb/overflow"
}
];
new ej.navigations.Breadcrumb({
items: items,
beforeItemRender: function(args) {
if (args.element.children[0]) {
args.element.children[0].target = "_blank";
}
}
}, '#breadcrumb');
<!DOCTYPE html><html lang="en"><head>
<title>Essential JS 2</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="Essential JS 2">
<meta name="author" content="Syncfusion">
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-navigations/styles/material.css" rel="stylesheet">
<!--style reference from app-->
<link href="styles.css" rel="stylesheet">
<!--system js reference and configuration-->
<script src="https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div class="control-section">
<nav id="breadcrumb"></nav>
</div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>