1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | AddBooks( [ { id: 1, name: 'Code Generation in Action', first: 'Jack', last: 'Herrington', publisher: 'Manning' }, { id: 2, name: 'PHP Hacks', first: 'Jack', last: 'Herrington', publisher: 'O\'Reilly' }, { id: 3, name: 'Podcasting Hacks', first: 'Jack', last: 'Herrington', publisher: 'O\'Reilly' } ] ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <html> <head> <title>Function 1 JS loader</title> <script> var g_books = []; function AddBooks( books ) { g_books = books; } </script> <script src="function1.js"></script> <script src="drawbooks.js"></script> </head> <body> <script>drawbooks( g_books );</script> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 | <xsl:template match="/"> AddBooks( [ <xsl:for-each select="books/book"> <xsl:if test="position() > 1">,</xsl:if> { id: <xsl:value-of select="@id" />, name: '<xsl:value-of select="js:escape(title)" />', first: '<xsl:value-of select="js:escape(author/first)" />', last: '<xsl:value-of select="js:escape(author/last)" />', publisher: '<xsl:value-of select="js:escape( publisher )" />' }</xsl:for-each> ] ); </xsl:template> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | function drawbooks( books ) { var elTable = document.createElement( 'table' ); for( var b in books ) { var elTR = elTable.insertRow( -1 ); var elTD1 = elTR.insertCell( -1 ); elTD1.appendChild( document.createTextNode( books.id ) ); var elTD2 = elTR.insertCell( -1 ); elTD2.appendChild( document.createTextNode( books.name ) ); var elTD3 = elTR.insertCell( -1 ); elTD3.appendChild( document.createTextNode( books.first ) ); var elTD4 = elTR.insertCell( -1 ); elTD4.appendChild( document.createTextNode( books.last ) ); var elTD5 = elTR.insertCell( -1 ); elTD5.appendChild( document.createTextNode( books.publisher ) ); } document.body.appendChild( elTable ); } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |