如何在多行警报框中调用Javascript函数?

时间:2011-08-03 04:51:57

标签: javascript quotes javascript-objects

我正在尝试显示一个警告框onpageload,它调用以前定义的函数。但是,它没有正确显示,因为字面上显示了对象属性mycircle.retArea和mycircle.retCirc。

<body onload="window.alert('The area of the circle is: + mycircle.retArea()\nThe circumference of the circle is: + mycircle.retCirc()');">

我猜我的报价有问题吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

尝试

<body onload="window.alert('The area of the circle is:' + mycircle.retArea() + '\nThe circumference of the circle is:' + mycircle.retCirc());">