Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Apply css to a popup

    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

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try: Select_box.document.body.setAttribute('class','selectbox');

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow className, not class

    Quote Originally Posted by Willy Duitt
    Try: Select_box.document.body.setAttribute('class','selectbox');
    according to MSDN you should say:
    setAttribute('className','selectbox')

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Willy Duitt
    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

    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.

  • #6
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •