You seem to be muddled about whether you are nesting XPath inside Javascript or vice versa. The obvious answer is that
<xsl:for-each select="//node/node[@id ='"+pageLink2+"']">
isn't well-formed XML so you can't write it. But more subtly, you are generating a <script> element in the target HTML page, which will execute when the page loads and perhaps when the user clicks on some button, and yet you seem to be trying to use the value of the Javascript variable during the transformation. If I have misunderstood what you are trying to do, sorry - it's hard to guess what people intended when the syntax is incorrect.
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference