473,499 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

attach stylesheet to iframe in Firefox (relative URI)

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>

Apr 16 '06 #1
3 5496
i donot now any thing i from K.S.A

Apr 16 '06 #2


ju************@chello.at wrote:

I have a problem in attaching an external stylesheet to a newly created
iframe in Firefox (1.5.0.2). oPanel = document.createElement("IFRAME");
oPanel.src = "about:blank";


Well what do you expect the browser to do with a relative URL if you
simply load about:blank in the window/frame? To resolve a relative URL a
base URL is needed but a document loaded from about:blank does not
really have one. Load a normal http: or file: URL in the frame and then
the browser is able to resolve a relative URL.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 16 '06 #3
Martin,

I thought the path of the onwner document was taken into consideration
in this case (IE seems to do this), well I was quite "IE-way-thinking"
and wrong. Thanks for clarification

lg

mord

Apr 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2325
by: Stéphane Mottelet | last post by:
Hi. How do you specify the document()'s arguments when the name of the document you want to load is obtained as a string, e.g. concat(@base,'.xml') ? The problem is that if the path of the...
3
12797
by: allard poldermans | last post by:
How can I make a reference to an external CSS or JS file that is relative to the XSL stylesheet, and not relative to the XML data? If you simply put : <link rel="stylesheet" type="text/css"...
24
4457
by: sinister | last post by:
After doing a websearch, it appears that it's OK to omit the "http:" to form a relative URL. Are there any pitfalls to this? For example, if there is a page http://www.domain1.com/page1.html...
1
4655
by: Martial Spirit | last post by:
Hello- I was amazed at the suckerfish drop-downs from AListApart.com. They work great except for one thing, if I position the drop-downs over an iframe element, on mouseover the menus disappear....
7
2679
by: Vincent van Beveren | last post by:
Hi everyone I have a JavaScript app that creates an IFRAME through DOM (createElement('IFRAME')) However, that IFRAME does not have any content yet. ...
4
27982
by: christine.nguyen | last post by:
Hello, Here's the deal. I have an html page that contains an iframe. This iframe has an id that is unknown to me. This iframe also has test.html as it's source. Within test.html runs some...
8
2590
by: JJ | last post by:
I'm confused about paths. I have a functionn that uses the mappath method, which I think requires a virtual path (is that the same as a relative path?). But this doesn't always work as the...
1
4493
by: IframeLearner | last post by:
Hi , I am trying to upload a file from a parent.jsp using Iframes. From Parent page. I have to save Subject, Desc, File and file name. to upload the file i am using Iframe. I want the...
2
1530
by: Paulson | last post by:
HI all I got a problem with my menu display.I am making a list as shown below in one of my aspx pages. And added a stylesheet in CSS for it. This is not working in IE but not in...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5479
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.