【问题标题】:Comment Box add text value without html评论框添加没有html的文本值
【发布时间】:2014-02-16 18:22:49
【问题描述】:

我有来自 htmlcommentbox.com 的默认评论框的代码 我想知道是否可以将文本值分配给名称字段 的评论框。请参阅http://htmlcommentbox.com 上的示例 如果没有,是否有另一个 cmets 插件可以为您提供 html 方面的功能 不只是一个 iframe?

<!-- begin htmlcommentbox.com -->
<div id="HCB_comment_box"><a href="http://www.htmlcommentbox.com">Comment Box</a> is              loading comments...</div>
<link rel="stylesheet" type="text/css" href="//www.htmlcommentbox.com/static/skins/bootstrap/twitter-bootstrap.css?v=0" />
<script type="text/javascript" id="hcb"> /*<!--*/ if(!window.hcb_user){hcb_user={};} (function(){var s=document.createElement("script"), l=(hcb_user.PAGE || ""+window.location), h="//www.htmlcommentbox.com";s.setAttribute("type","text/javascript");s.setAttribute("src", h+"/jread?page="+encodeURIComponent(l).replace("+","%2B")+"&opts=16862&num=10");if (typeof s!="undefined") document.getElementsByTagName("head")[0].appendChild(s);})(); /*-->*/ </script>
<!-- end htmlcommentbox.com -->

【问题讨论】:

    标签: javascript jquery html text comments


    【解决方案1】:

    好的,将此脚本添加到 html 注释框上方,您可以对其进行编辑:

    <!-- customize labels of htmlcommentbox.com -->
    <script>
    // This code goes ABOVE the main HTML Comment Box code!
    // replace the text in the single quotes below to customize labels.
    hcb_user = {
    //L10N
    comments_header : 'Comments',
    name_label : 'Name',
    content_label: 'Enter your comment here',
    submit : 'Comment',
    logout_link : '<img title="log out" src="//www.htmlcommentbox.com/static/images/door_out.png" alt="[logout]" class="hcb-icon"/>',
    admin_link : '<img src="//www.htmlcommentbox.com/static/images/door_in.png" alt="[login]" class="hcb-icon"/>',
    no_comments_msg: 'No one has commented yet. Be the first!',
    add:'Add your comment',
    again: 'Post another comment',
    rss:'<img src="//www.htmlcommentbox.com/static/images/feed.png" class="hcb-icon" alt="rss"/> ',
    said:'said:',
    prev_page:'<img src="//www.htmlcommentbox.com/static/images/arrow_left.png" class="hcb-icon" title="previous page" alt="[prev]"/>',
    next_page:'<img src="//www.htmlcommentbox.com/static/images/arrow_right.png" class="hcb-icon" title="next page" alt="[next]"/>',
    showing:'Showing',
    to:'to',
    website_label:'website (optional)',
    email_label:'email',
    anonymous:'Anonymous',
    mod_label:'(mod)',
    subscribe:'email me replies',
    are_you_sure:'Do you want to flag this comment as inappropriate?',
    
    reply:'<img src="//www.htmlcommentbox.com/static/images/reply.png"/> reply',
    flag:'<img src="//www.htmlcommentbox.com/static/images/flag.png"/> flag',
    like:'<img src="//www.htmlcommentbox.com/static/images/like.png"/> like',
    
    //dates
    days_ago:'days ago',
    hours_ago:'hours ago',
    minutes_ago:'minutes ago',
    within_the_last_minute:'within the last minute',
    
    msg_thankyou:'Thank you for commenting!',
    msg_approval:'(this comment is not published until approved)',
    msg_approval_required:'Thank you for commenting! Your comment will appear once approved by a moderator.',
    
    err_bad_html:'Your comment contained bad html.',
    err_bad_email:'Please enter a valid email address.',
    err_too_frequent:'You must wait a few seconds between posting comments.',
    err_comment_empty:'Your comment was not posted because it was empty!',
    err_denied:'Your comment was not accepted.',
    
    //SETTINGS
    MAX_CHARS: 2048,
    PAGE:'', // ID of the webpage to show comments for. defaults to the webpage the user is currently visiting.
    RELATIVE_DATES:true // show dates in the form "X hours ago." etc.
    };
    </script>
    <!-- done customizing labels of htmlcommentbox.com -->
    

    【讨论】:

    • 非常感谢您的宝贵时间!
    【解决方案2】:

    您是指消失的灰色文本还是您希望它具有起始值?

    对于在该部分处于焦点时消失的灰色文本,请使用:

    placeholder="Whatever you want"
    

    作为起始值使用:

    value="Whatever you want"
    

    【讨论】:

    • 我知道占位符和值属性,但我没有文本框的 html 代码块,那么我将如何分配它们?
    • 我会添加另一个答案使用那个
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-13
    • 2022-11-18
    • 2014-05-20
    相关资源
    最近更新 更多