English 中文(简体)
JavaScript 被禁用时 Cs 后退
原标题:Css fallback when JavaScript is disabled

与jQuery Mobile, 我用这个片段叫解放者...

<script src="//code.jquery.com/jquery-1.6.4.min.js"></script>
<script>
if(typeof jQuery ===  undefined ) 
{
    document.write(unescape( %3Cscript src="js/jquery-1.6.4.min.js"%3E%3C/script%3E ));
    document.write(unescape( %3Cscript src="jqm/jquery.mobile-1.1.0.min.js"%3E%3C/script%3E ));     
    document.write(unescape( %3Clink rel="stylesheet" href="jqm/jquery.mobile-1.1.0.min.css"%3E%3C/script%3E ));
    document.write(unescape( %3Clink rel="stylesheet" href="jqm/jquery.mobile.structure-1.1.0.min.css"%3E%3C/script%3E ));
}
else
{
    document.write(unescape( %3Cscript src="//code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"%3E%3C/script%3E ));
    document.write(unescape( %3Clink rel="stylesheet" href="//code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css"%3E%3C/script%3E ));
    document.write(unescape( %3Clink rel="stylesheet" href="//code.jquery.com/mobile/1.1.0/jquery.mobile.structure-1.1.0.min.css"%3E%3C/script%3E ));
}
</script>

但如果 JavaScript 已禁用, 如何调用样式表?

如果我使用(我有点笨! )...

<noscript>
<link rel="stylesheet" href="jqm/jquery.mobile-1.1.0.min.css" />
<link rel="stylesheet" href="jqm/jquery.mobile.structure-1.1.0.min.css" />
</noscript>

...我的页面是空白的。

谢谢你的帮助

文森森特

最佳回答

< a href=> "http://modernizr.com/" rel="nofollow" >Modernizr 的方法是使用 JavaScript 在装入的 HTML 标记中添加一个名为“ js” 的类, 并删除一个名为“ no-js” 的类, 也就是( 在这种情况下) 你添加自己 的类 。

现在,您可以只将某些 CSS 样式添加到 .js 的后代身上,而其它样式则只添加到 .no-js 的后代身上,按您的喜好定制任何一种。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签