J
juergen.riemer
Hi all,
I have a problem in attaching an external stylesheet to a newly created
iframe in Firefox (1.5.0.2).
If I use the code below (with a relative address to the file) the
stylesheet would not be applied.
I have to indicate the absolute path:
var uriStylesheet = "http://localhost:8080/panel/styles.css";
to make it work in Firefox.
NB: if I try to attach the external stylesheet to the topmost body (the
main document) I could use the relative path without a problem.
any ideas?
greetz
mord
<html>
<body>
<script>
oPanel = document.createElement("IFRAME");
oPanel.src = "about:blank";
document.body.appendChild(oPanel);
oPanel.addEventListener("load", function(){
var oImage = oPanel.contentDocument.createElement("IMG");
oPanel.contentDocument.body.appendChild(oImage);
attachStylesheet();
}, false);
function attachStylesheet(){
var uriStylesheet = "/jPanel/styles.css";
var uriStylesheet = "http://localhost:8080/panel/styles.css";
var oStylesheet = oPanel.contentDocument.createElement("LINK");
oStylesheet.rel = "stylesheet";
oStylesheet.type = "text/css";
oStylesheet.href = uriStylesheet;
var oHead = oPanel.contentDocument.getElementsByTagName('head')[0];
if(oHead){
oHead.appendChild(oStylesheet);
}
}
</script>
</html>
</body>
I have a problem in attaching an external stylesheet to a newly created
iframe in Firefox (1.5.0.2).
If I use the code below (with a relative address to the file) the
stylesheet would not be applied.
I have to indicate the absolute path:
var uriStylesheet = "http://localhost:8080/panel/styles.css";
to make it work in Firefox.
NB: if I try to attach the external stylesheet to the topmost body (the
main document) I could use the relative path without a problem.
any ideas?
greetz
mord
<html>
<body>
<script>
oPanel = document.createElement("IFRAME");
oPanel.src = "about:blank";
document.body.appendChild(oPanel);
oPanel.addEventListener("load", function(){
var oImage = oPanel.contentDocument.createElement("IMG");
oPanel.contentDocument.body.appendChild(oImage);
attachStylesheet();
}, false);
function attachStylesheet(){
var uriStylesheet = "/jPanel/styles.css";
var uriStylesheet = "http://localhost:8080/panel/styles.css";
var oStylesheet = oPanel.contentDocument.createElement("LINK");
oStylesheet.rel = "stylesheet";
oStylesheet.type = "text/css";
oStylesheet.href = uriStylesheet;
var oHead = oPanel.contentDocument.getElementsByTagName('head')[0];
if(oHead){
oHead.appendChild(oStylesheet);
}
}
</script>
</html>
</body>