...

View Full Version : Apply css to a popup



echo1
05-31-2004, 10:04 PM
Hi
I'm building a selectbox insead of using the common select tag.
I use the windows.createpopup() method to display the list of choise.
Differently to the div object the popup object is like a new window so it doesn't inherit the css style sheet I've attached to the main window.
I tought to attach it by using the addImport(url) method of the styleSheet object but it doesn't seem to work. Here it's my code, the show function it's called when the selectbox expands:

var Select_box = window.createPopup();
Select_box.document.styleSheets[0].addImport("URL('common/css/default_style.css');")

function show(element) {
if (Select_box.isOpen==false) {
Select_box.document.body.innerHTML = Select_box_content.innerHTML;
Select_box.document.body.className='selectbox';
Select_box.show(0, 18, 150, 50, element);
}
else {
Select_box.hide();
}
}

I've noticed that using the addImport method on the main window, and not on the instance of the select_box, with 0 index of the styleSheet the error doesn't occur but it doesn't also change the proprety. Tring using any other index value it gives me the usual error.
So how can I attach a style sheet to a popup created with the window.createpopup()?

Thank you

Willy Duitt
06-04-2004, 07:50 AM
Try: Select_box.document.body.setAttribute('class','selectbox');

jbot
06-04-2004, 11:27 AM
Try: Select_box.document.body.setAttribute('class','selectbox');

according to MSDN you should say:
setAttribute('className','selectbox')

Willy Duitt
06-04-2004, 11:59 AM
Are you sure? and if so, could you provide a link over at the MSDN Library (I have Active X disabled and their menu doesn't work for me)

I know I have previously had problems using class versus className but I have always worked it out by trying the other if one doesn't work. :o

jbot
06-04-2004, 12:06 PM
Are you sure? and if so, could you provide a link over at the MSDN Library (I have Active X disabled and their menu doesn't work for me


MSDN reference (http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/setattribute.asp?frame=true)

the text to look out for appears just before the line "standards information" which appears in bold towards the bottom of the document.

I've had problems to with this method, however, and ended up using the standard object.className=sString method.

hope that clears things up a little, Willy. :D

Willy Duitt
06-04-2004, 12:12 PM
Thank you very much :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum