如何在javascript值中插入html代码?

时间:2015-10-19 17:00:20

标签: javascript html

在Java Flo中添加此HTML代码的方法

例如: 这个:

https://jsfiddle.net/asfarmohamed/3oukv31s/

在此脚本中:

setDragMode(QGraphicsView::RubberBandDrag);

    
    Pro Roseic Facebook POP-UP Box by Widget Generators
    
    
    
    ;
    function RWGcodegen(){
    var RWGfb = document.getElementsByName("fb")[0].value
    var widget=document.getElementsByName("widget.content")[0];

    widget.value += "  "; 
    widget.value += "  "; 
    widget.value += "  "; 
    widget.value += " function r(f){\/in\/.test(document.readyState)?setTimeout('r('+f+')',9):f()}; r(function(){new ConversionsBox(\"Like%20Us%20On%20Facebook\",\"http:\/\/www.facebook.com\/"+ RWGfb +"\");}); "; 
    widget.value += "  "; 
    widget.value += "  "; 

    document.getElementsByName("go")[0].disabled = false;
              document.getElementsByName("preview")[0].disabled = false;
            }

    function RWGpredemo(){
    var demodata = document.getElementsByName('RWGjs')[0].value + document.getElementsByName('widget.content')[0].value;
    newwindow = window.open('', 'name', '');
    var tmp = newwindow.document;
    tmp.write('' + demodata + '');
    tmp.close();
    }

    function RWGReset(){
    var widget=document.getElementsByName("fb")[0].value="hooter-spot"
    var widget=document.getElementsByName("widget.content")[0].value=""
    }
    

          
    body{background:#000 url(http://www.3dwallpaper.org/walls/digital_matrix_neon_background-wide.jpg) repeat;
    }/*atau no-repeat fixed center, no-repeat center, dll (sesuaikan dengan size gambar)*/
    
    
    
    Facebook POP-UP Box Generator  

    

    
    .input-text,.text-input, .select-box{
     margin:0 2px;
     padding:4px 6px;
     border: 1px solid #434343;
     -webkit-border-radius: 4px;
     -moz-border-radius: 4px;
     border-radius: 4px;
     font-family: gergia;
     font-style: italic;
     -webkit-box-shadow: 4px 4px 4px #434343;
     -moz-box-shadow: 4px 4px 4px #434343;
     box-shadow: 4px 4px 4px #434343;
     font-size: 14px;
     color: #666;
     max-width:auto;
    }
    .textarea-box, .textareaBox{
     border:2px dotted #7C7B7B;
     padding:6px;
     -webkit-resize: none;
     -moz-resize: none;
     resize: none;
     -webkit-box-shadow: 4px 4px 4px #434343;
     -moz-box-shadow: 4px 4px 4px #434343;
     box-shadow: 4px 4px 4px #434343;
     -webkit-border-radius: 8px;
     -moz-border-radius: 8px;
     border-radius: 8px;
    }


    .redius{
    -moz-border-radius: 10px;
    -webkit-border-radius: 10px;
    border-radius: 10px; }
    }
    #RWGgadform {
        font-family: Georgia, serif;
    }

    #RWGgadmn fieldset {
        border: 2px dotted #000000;
        background: #ffffff;
        padding: 0 20px;
    }

    #RWGgadmn legend {
        background-color:#434343;
        background: -moz-linear-gradient(center top , #000000 0%, #434343 100%) repeat scroll 0 0 transparent;
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0090f7), color-stop(100%,#1f5ea2));
    background: -webkit-linear-gradient(top, #0090f7 0%,#1f5ea2 100%);
    background: -o-linear-gradient(top, #0090f7 0%,#1f5ea2 100%);
    background: -ms-linear-gradient(top, #0090f7 0%,#1f5ea2 100%);
    background: linear-gradient(top, #0090f7 0%,#1f5ea2 100%);
        border: 2px solid;
        border-radius: 14px 14px 14px 14px;
        color: #FFFFFF;
        font: 21px arial,Sans MS;
        padding: 4px;
        text-align: center;
        text-shadow: 1px 1px 1px #000000;
    }


    #RWGgad fieldset {
        border: 2px solid #000000;
        background: #FFFFFF;
        padding: 0 20px;
    }
    #RWGgad legend {
    background-color:#434343;
        background: -moz-linear-gradient(center top , #000000 0%, #434343 100%) repeat scroll 0 0 transparent;
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0090f7), color-stop(100%,#1f5ea2));
    background: -webkit-linear-gradient(top, #0090f7 0%,#1f5ea2 100%);
    background: -o-linear-gradient(top, #0090f7 0%,#1f5ea2 100%);
    background: -ms-linear-gradient(top, #0090f7 0%,#1f5ea2 100%);
    background: linear-gradient(top, #0090f7 0%,#1f5ea2 100%);
        border: 2px solid;
        border-radius: 14px 14px 14px 14px;
        color: #FFFFFF;
        font: 17px arial,Sans MS;
        padding: 4px;
        text-align: center;
        text-shadow: 1px 1px 1px #ffffff;
    }

    .RWGbtn {
        background: -moz-linear-gradient(center top , #F4F4F4 0%, #D8E1E7 100%) repeat scroll 0 0 transparent;
        background-color:#F4F4F4;
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f4f4f4), color-stop(100%,#d8e1e7));
    background: -webkit-linear-gradient(top, #f4f4f4 0%,#d8e1e7 100%);
    background: -o-linear-gradient(top, #f4f4f4 0%,#d8e1e7 100%);
    background: -ms-linear-gradient(top, #f4f4f4 0%,#d8e1e7 100%);
    background: linear-gradient(top, #f4f4f4 0%,#d8e1e7 100%);
        border: 1px solid #A8B5BF;
        border-radius: 3px 3px 3px 3px;
        cursor: pointer;
        padding: 4px 14px;
    }

    .RWgbtn:hover {
        background: none repeat scroll 0 0 #D8E1E7;
    }

    

    
    
    Customize
    
    
    FaceBook Page ID
    : 
    




    
    
    
    
Application / Buttons
Generated Code



| hooter-spot

2 个答案:

答案 0 :(得分:1)

更新: -

我明白你在找什么。运行此HTML,您将获得它。

<html>
<body

<div id = "htmls"></div>

<script>
    var b = "<input type='button' value ='click'>  ";
    document.getElementById("htmls").innerText = b;
</script>


</body>
</html>

假设您有一个包含按钮HTML代码的变量。

var b = "<input type='button' value='click'>"

现在你可以做这样的事情 -

document.write(b);

这将显示一个包含变量b的HTML代码的html页面。请记住,您应该遵循引号规则。这里变量b的值写在两个双引号内。

时请注意
type = 'button'

写的,使用单引号。希望你明白

答案 1 :(得分:0)

只需像

一样添加
widget.value += "<div> this is html </div>";