Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Apr 2003
    Akron Ohio USA

    s60 browser cssRules.selectorText formatting issue

    I am working on a WRT project where I need to create a style object from a given style sheet rule selector text. I have one funtion that reads through all style rules in each style sheet and looks for selectorText matching the string I provide, then returns the corresponding style object.

    Unforunately it seems the s60 browser reformats css style rule names in the selectorText property into a non standard format. All other browsers seem to return the selectorText as it is listed in the style sheet.

    It seems the s60 browser converts id selectors into the following format.

    #selectortext /* as it appears in the style sheet */

    *[ID"selectortext"] /* as reported by s60 browser javascript from the selectorText property */

    It also capitalizes all tag selectors

    body /* as it appears in style sheet */
    BODY /* as returned by javascript */

    This reformatting makes it difficult to find a style from its selector name using Javascript because the name you include in the style sheet is not how javascript reads it.

    I created the following function to reformat a given selector name string into the s60 format I describe above, so I can use another function to more easily create a style object for a given rule.

    s60 browser converts format of selectors
    id selectors: #selectorText = *[ID"selectorText"]
    s60 also converts tag selectors to upper case
    function format_selectorText_for_s60(selector){
    	if(selector.indexOf("#") > -1){ // find id selectors
    		// replace all instances of # with *[ID"
    		var id_selectorText = selector.replace(/#/g,'*[ID"');
    		var selectors = id_selectorText.split(" ");
    		for(var k=0; k<selectors.length; k++){ // loop through each word in selector string
    			if(selectors[k].indexOf("*[ID") > - 1){ // add closing "] for id selectors
    				selectors[k] += '"]';
    			} else if(selectors[k].indexOf(".") == -1){ // convert tag selectors to upper case
    				selectors[k] = selectors[k].toUpperCase();
    			} else {}
    		selector = selectors.join(" "); // rebuild selector text with reformatted strings
    	} else if(selector.indexOf(".") == -1){ // convert tag selectors to upper case
    		selector = selector.toUpperCase();
    	} else {}
    	return selector;
    has anyone else encountered this problem and how are you dealing with it?

  2. #2
    Regular Contributor
    Join Date
    Apr 2003
    Akron Ohio USA

    Re: s60 browser cssRules.selectorText formatting issue

    here is code to show what values s60 browser returns for selectorText property.

    var sheetList = document.styleSheets; // get list of all style sheets
    /* look through stylesheets */
    	for (i=sheetList.length-1; i >= 0; i--){
    		ruleList = sheetList[i].cssRules;
    		/* loop through rules of selected style sheet */
    		for (j=0; j<ruleList.length; j++){
                            // get the selector text for the given rule
    			var CSS_selectorText = ruleList[j].selectorText; 		

Similar Threads

  1. Javascript Support for S60 Browser
    By swetha_t in forum Browsing and Mark-ups
    Replies: 2
    Last Post: 2009-07-10, 10:01
  2. S60 Bluetooth issue
    By markdevries in forum Mobile Java Networking & Messaging & Security
    Replies: 10
    Last Post: 2007-09-04, 11:17
  3. No key events in S60 browser
    By trapd in forum Mobile Web Site Development
    Replies: 0
    Last Post: 2007-06-14, 11:25
  4. Replies: 4
    Last Post: 2006-05-15, 17:02
  5. UID for web browser in s60 3rd?
    By ppiggy in forum Symbian C++
    Replies: 0
    Last Post: 2006-01-18, 14:22

Posting Permissions

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