开发者

jQuery: How can I get the HTML from inside NoScript to display in a differend div tag?

I've got a small script that detects if the user is using a certain browser

var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if(is_chrome){
    $('.ifChrome').attr('style', 'display:block;');
    $('.ifChrome').html($('noscript > div').html());
};

If they are using this browser, we want to display a div tag and show the HTML from a different div tag inside.

<noscript>
    <div class="note">
        Your browser does not properly support the WMD Markdown Editor.<br />
        Please use <a href="/about/markdown" target="_blank">Markdown<.a> to style your input.
    </div>
</noscript>
<div class="hidden ifChrome note"></div>

What I'm trying to do is show the "not supported" text from inside my <noscript> tag to users 开发者_运维知识库who are using this browser (because WMD Markdown doesn't work properly with it).

My existing Javascript is not working. Any help would be greatly appreciated.


This is a bit late but you can do:

var noscriptContents = $($('noscript').html());
$('.ifChrome').append(noscriptContents);


You cannot access the content of a noscript-element using javascript in chrome. So you'll have to find a different approach that doesn't use a noscript-element. Read more about that problem here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜