SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2006
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is "content" a property of the window object that's just not documented often?

    Hi
    I have adapted some code for my purposes but the lines in the code I am posting below with the apparent window property of "content" have not changed from the code originally given to me. And this code works spitting out in a new window all rules of a stylesheet connected to your HTML. Thought maybe "content" was a user created property so I tried creating a custom property by changing the "content" word in the code below to other nonsense words like ABC or XXX and these nonsense words don't work. So I think the code below is not creating a property in the word "content" on-the-fly. So where is this "content" property of the window object documented. Google searches on not turning up references that yield "content" as a property or method. So please tell me what's going on.

    Sincerely
    Marc

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>hello red rule</title>
    <style type="text/css" media="screen">
    body {background-color:red;}
    h1 {color:blue;
        font-style:italic;
    }
    p {
    	 color:black;
    	 background-color:green;
    }
    </style>	
    <script type="text/javascript" charset="utf-8">
    
    function styleAllRules(styleShNum){
    	var rules = "";	
    	var allRules = document.styleSheets[styleShNum].cssRules;
    		for(var i=0;i<allRules.length;i++)
    		{
    			rules +=  i + "\b  \b" + "\b  \b" + "\b  \b" 
    			              + allRules[i].cssText + "<br/>";			
    		}	
      var win = window.open('about:blank');
      win.content.document.write(rules);
      win.content.document.close();
    };
    window.onload = function(){
     styleAllRules(0)	
    };
    </script>
    
    </head>
    
    <body>
    <h1>hello</h1>
    <p>from par</p>
    </body>
    </html>

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Only on mozilla (gecko) browsers.
    Try window===content.

    Its a firefox & co. euphemism for the dom defaultView

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2006
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes here the link. Thanks!


Bookmarks

Posting Permissions

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