开发者

javascript calling function

var macs = {
    getMacAddress : function()
    {
        document.macaddressapplet.setSep( "-" );
        document.write( "Mac Address = " + document.macaddressapplet.getMacAddress() );
    }

how do i call this function and display out in the website?

this doesn't see开发者_Python百科ms working..

<script type="text/javascript">
    document.write(mac.getMacAddress());
</script>

Anyone help?


Just use macs.getMacAddress();

The function doesn't return anything. It simply writes to the document. If you want it to return the string, replace document.write with return when you define macs.

Also, note that calling document.write after the page is loaded will overwrite the current page (because it implies document.open). If you need to append to the document after it's loaded, use the DOM or innerHTML.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜