Search code examples
htmlcssnoscriptdolphin-browser

noscript section being read by dolphin


Dolphin Browser and the Default Android Browser are reading the <noscript> section in the head of my page even though javascript is turned on in those browsers. This causes the content of those pages not to be rendered.

In the head I link to a a css stylesheet that sets display to none for anything inside a div on page when javascript is turned off in the browser. It does this by residing inside a nonscript element, so the stylesheet is only read if there is no javascript.

This works for all desktop/laptop browsers I tested (not tested on mac which I don't have access to). It works on Android with Firefox and Opera. I have cyanongenmod 7 only so no Google Chrome for me.

However when it comes to Dolphin and the default Android browsers, they read the css stylesheet that resides in the noscript section and pretty much the whole page/site is not rendered in these browsers.

I have proven that this is what is happening by deleting the stylesheet link from the head section and the page renders correctly in those browsers.

Is there some way to get these browsers to respect the noscript tags in the head section?

UPDATE: This is using HTML5 - noscript in the head is allowed: http://www.w3.org/TR/html5/the-noscript-element.html#the-noscript-element

<!DOCTYPE html>
<html>
<head>
        <noscript>
            <link href="${facesContext.externalContext.requestContextPath}/css/no_javascript.css" rel="stylesheet" type="text/css" />
            <!-- this link is being read even if javascript in enabled in dolphin -->
        </noscript>

</head>
<body>
    <noscript>
        stuff in this noscript element works correctly
    </noscript>

    <div class="no_javascript_disapear">

        page full of stuff not being rendered because 
        dolphin browser is not respecting the noscript 
        tags in the head.

    </div>
</body>
</html>

// css in the noscript tag:
.no_javascript_disapear {display:none;}

Solution

  • Maybe you can use javascript to remove that stylesheet?

    Read this question for how to Access Contents of <noscript> with Javascript


    Otherwise, you can add a title to your no-js stylesheet:

    <link title="noJsStylesheet"  href="....css" rel="stylesheet" type="text/css" />
    

    And use this function to remove it:

    for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
        if(a.getAttribute("title") == 'noJsStylesheet') a.disabled = true;
    }
    

    But i'm really not sure if it'll work on this specific Dolphin version.