aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-04-03 17:22:47 +0200
committerRobert Jaros <rjaros@finn.pl>2018-04-03 17:22:47 +0200
commit946d432023da1e2bb60c8d4c7260a6d486f7f53b (patch)
tree3fcb3f3c2e01b25d44aabd0e32bec3f6b3da4a53 /src
parent870fd9ba525d117b1e9cc1227ea8ddc33204e747 (diff)
downloadkvision-946d432023da1e2bb60c8d4c7260a6d486f7f53b.tar.gz
kvision-946d432023da1e2bb60c8d4c7260a6d486f7f53b.tar.bz2
kvision-946d432023da1e2bb60c8d4c7260a6d486f7f53b.zip
Access to the content window object.
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Iframe.kt18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Iframe.kt b/src/main/kotlin/pl/treksoft/kvision/html/Iframe.kt
index d9c97ea7..e13441c2 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Iframe.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Iframe.kt
@@ -4,6 +4,7 @@
package pl.treksoft.kvision.html
import com.github.snabbdom.VNode
+import org.w3c.dom.Window
import pl.treksoft.kvision.core.Container
import pl.treksoft.kvision.core.StringPair
import pl.treksoft.kvision.core.Widget
@@ -64,9 +65,9 @@ open class Iframe(
* A current location URL of the iframe.
*/
var location: String?
- get() = getLocation()
+ get() = getLocationHref()
set(value) {
- setLocation(value)
+ setLocationHref(value)
}
override fun render(): VNode {
@@ -97,14 +98,23 @@ open class Iframe(
}
@Suppress("UnsafeCastFromDynamic")
- private fun getLocation(): String? {
+ private fun getLocationHref(): String? {
return getElementJQueryD()[0].contentWindow.location.href
}
- private fun setLocation(location: String?) {
+ private fun setLocationHref(location: String?) {
getElementJQueryD()[0].contentWindow.location.href = location ?: "about:blank"
}
+ /**
+ * Returns content window object of the iframe.
+ * @return content window object
+ */
+ @Suppress("UnsafeCastFromDynamic")
+ open fun getIframeWindow(): Window {
+ return getElementJQueryD()[0].contentWindow
+ }
+
companion object {
/**
* DSL builder extension function.