如何在这个javascript中使用html标签?

时间:2014-10-05 16:23:35

标签: javascript html css oop

如何在此javascript中使用html标签?

首先,为什么<br>在提示中不起作用。其次,为什么我不能使用此代码的标签(poundOne.pound)通过使用css或html代码(例如<h1><h2><h3>来使字体更大...还是<div style="......">

<html>
<head>
<script type="text/javascript">


function poundToKgConvertor( pound ){
    this.pound = pound;
    this.convertorDon = convertor;
}
function convertor(){
    var convert = this.pound * 0.453592;
    return convert;
}

var poundOne = new poundToKgConvertor(prompt ("Convert Pound to Kilogram!<br> Please insert your    number of pound!"));
</script>

</head>

<body>

<script type="text/javascript">


document.write(poundOne.pound +  " Pound = " + poundOne.convertorDon() + " <b>Kilogram</b>");

</script>

</body>
</html>

1 个答案:

答案 0 :(得分:2)

您无法在提示/警告对话框中使用HTML。但是,您可以使用换行符:

prompt ("Convert Pound to Kilogram!\n Please insert your number of pound!");