I\'m opening new page using JS and writing into it the HTML code, however when I try to write JS inside the new page using document.write() function it doesn\'
document.write()
EDIT: as others pointed out, you should escape the slash with a backslash.
The easy (but non standard) solution is to break your string:
opened.document.write("");