Christoph Hock
04/07/2021, 8:29 PMfun reloadCss() {
val iframe = document.getElementById("iframe-id")
println("Test0")
if (iframe != null && iframe is HTMLIFrameElement) {
val contentWindow = iframe.contentWindow
if (contentWindow == null) {
println("Null1")
return
}
val link = contentWindow.document.getElementById("css-link")
if (link == null) {
println("Null2")
return
}
console.log("Typeof is" + jsTypeOf(link))
console.log(link::class)
if (link is HTMLLinkElement){
val href: String = link.href.split('?')[0]
link.href = "$href?version=${currentTimeMillis()}"
println("Test1")
}
val cssLink = link.unsafeCast<HTMLLinkElement>()
val href: String = cssLink.href.split('?')[0]
cssLink.href = "$href?version=${currentTimeMillis()}"
println("Test2")
}
}
When the code above is executed the console output is as follows:Christoph Hock
04/07/2021, 8:32 PM