2020-09-29 13:13:49 +00:00
---
layout: page
title: IFrame Plugin
---
The iframe plugin provides the functionality to open sidebar & navbar items in a tabbed iframe.
##### Required Markup
To get the iframe 100% working you need the following content-wrapper markup:
```html
< div class = "content-wrapper iframe-mode" data-widget = "iframe" data-loading-screen = "750" >
< div class = "nav navbar navbar-expand-lg navbar-white navbar-light border-bottom p-0" >
< a class = "nav-link bg-danger" href = "#" data-widget = "iframe-close" > Close< / a >
< ul class = "navbar-nav" role = "tablist" > < / ul >
< / div >
< div class = "tab-content" >
< div class = "tab-empty" >
< h2 class = "display-4" > No tab selected!< / h2 >
< / div >
< div class = "tab-loading" >
< div >
< h2 class = "display-4" > Tab is loading < i class = "fa fa-sync fa-spin" > < / i > < / h2 >
< / div >
< / div >
< / div >
< / div >
```
2021-03-04 07:10:05 +00:00
###### Markup with Default IFrame Tab
```html
< div class = "content-wrapper iframe-mode" data-widget = "iframe" data-loading-screen = "750" >
< div class = "nav navbar navbar-expand-lg navbar-white navbar-light border-bottom p-0" >
< a class = "nav-link bg-danger" href = "#" data-widget = "iframe-close" > Close< / a >
< a class = "nav-link bg-light" href = "#" data-widget = "iframe-scrollleft" > < i class = "fas fa-angle-double-left" > < / i > < / a >
< ul class = "navbar-nav" role = "tablist" >
2021-07-12 19:28:23 +00:00
< li class = "nav-item active" role = "presentation" >
< a href = "#" class = "btn-iframe-close" data-widget = "iframe-close" data-type = "only-this" > < i class = "fas fa-times" > < / i > < / a >
< a class = "nav-link active" data-toggle = "row" id = "tab-index-html" href = "#panel-index-html" role = "tab" aria-controls = "panel-index-html" aria-selected = "true" > Dashboard v1< / a >
< / li >
2021-03-04 07:10:05 +00:00
< / ul >
< a class = "nav-link bg-light" href = "#" data-widget = "iframe-scrollright" > < i class = "fas fa-angle-double-right" > < / i > < / a >
< a class = "nav-link bg-light" href = "#" data-widget = "iframe-fullscreen" > < i class = "fas fa-expand" > < / i > < / a >
< / div >
< div class = "tab-content" >
< div class = "tab-pane fade active show" id = "panel-index" role = "tabpanel" aria-labelledby = "tab-index" > < iframe src = "./index.html" style = "height: 671px;" > < / iframe > < / div >
< div class = "tab-empty" >
< h2 class = "display-4" > No tab selected!< / h2 >
< / div >
< div class = "tab-loading" >
< div >
< h2 class = "display-4" > Tab is loading < i class = "fa fa-sync fa-spin" > < / i > < / h2 >
< / div >
< / div >
< / div >
< / div >
```
2020-09-29 13:13:49 +00:00
##### Usage
2021-02-19 06:54:52 +00:00
This plugin can be activated as a jQuery plugin or using the data api.
2020-09-29 13:13:49 +00:00
###### Data API
{: .text-bold }
2021-02-19 06:54:52 +00:00
Activate the plugin by adding `data-widget="iframe"` to the `.content-wrapper` . If you need to provide onCheck and onUncheck methods, please use the jQuery API.
2020-09-29 13:13:49 +00:00
###### jQuery
{: .text-bold }
2021-02-19 06:54:52 +00:00
The jQuery API provides more customizable options that allows the developer to handle checking and unchecking the todo list checkbox events.
2020-09-29 13:13:49 +00:00
```js
$('.content-wrapper').IFrame({
onTabClick(item) {
return item
},
onTabChanged(item) {
return item
},
onTabCreated(item) {
return item
},
autoIframeMode: true,
autoItemActive: true,
autoShowNewTab: true,
2021-07-12 19:28:23 +00:00
autoDarkMode: false,
2021-02-10 07:41:59 +00:00
allowDuplicates: true,
2020-09-29 13:13:49 +00:00
loadingScreen: 750,
useNavbarItems: true
})
```
##### Options
{: .mt-4}
|---
| Name | Type | Default | Description
|-|-|-|-
|onTabClick | Function | Anonymous Function | Handle tab click event.
|onTabChanged | Function | Anonymous Function | Handle tab changed event.
|onTabCreated | Function | Anonymous Function | Handle tab created event.
|autoIframeMode | Boolean | true | Whether to automatically add `.iframe-mode` to `body` if page is loaded via iframe.
|autoItemActive | Boolean | true | Whether to automatically set the sidebar menu item active based on the active iframe.
|autoShowNewTab | Boolean | true | Whether to automatically display created tab.
2021-07-12 19:28:23 +00:00
|autoDarkMode | Boolean | false | Whether to automatically enable dark-mode in iframe pages.
2021-02-10 07:41:59 +00:00
|allowDuplicates | Boolean | true | Whether to allow creation of duplicate tab/iframe.
2020-09-29 13:13:49 +00:00
|loadingScreen | Boolean/Number | true | [Boolean] Whether to enable iframe loading screen; [Number] Set loading screen hide delay.
|useNavbarItems | Boolean | true | Whether to open navbar menu items, instead of open only sidebar menu items.
|---
{: .table .table-bordered .bg-light}
##### Methods
{: .mt-4}
|---
| Method | Description
|-|-
2020-09-30 07:04:42 +00:00
|createTab| Create tab by title, link & uniqueName. Available arguments: title `String` , link `String` , uniqueName `String` , autoOpen `Boolean/Optional` .
|openTabSidebar| Create tab by sidebar menu item. Available arguments: item `String|jQuery Object` , autoOpen `Boolean/Optional` .
|switchTab| Switch tab by iframe tab navbar item. Available arguments: item `String|jQuery Object` .
|removeActiveTab| Remove active iframe tab.
2020-09-29 13:13:49 +00:00
{: .table .table-bordered .bg-light}
2020-09-30 07:04:42 +00:00
Example: `$('.content-wrapper').IFrame('createTab', 'Home', 'index.html, 'index', true)`