window.open() and the JavaScript content in the new window.

Discussion in 'Javascript' started by IveCal, Apr 2, 2007.

  1. IveCal

    IveCal Guest

    Hello, I created the following sample HTML/JavaScript of my problem. I
    have a MAIN page. When it is loaded, I want to open a new window that
    contains the same JavaScript as the main window:

    <script type="text/javascript" >
    alert("OK");
    </script>

    My problem here is the new window have an error: Object expected. This
    is the source code of the new window:

    <html><body><table><TR>
    <SCRIPT type=text/javascript>
    alert("OK");
    </SCRIPT>
    </TR></table></body></html>

    I realize the problem is in the second line where the text/javascript
    is not enclosed in double quotes so that it looks like this: <SCRIPT
    type="text/javascript">

    I have no idea how to solve this problem. Please help. Thanks a lot.


    ------------------------------------------------------------------

    Sample Main HTML





    <script language="javascript">
    function replaceQuote(strTemp)
    {
    return strTemp.replace(/"/gi,"'");
    }
    </script>


    <html>
    <body>
    <table>
    <tbody name="test" id="test">
    <tr>
    <script type="text/javascript" >
    alert("OK");
    </script>
    </tr></tbody>
    </table>

    <table>
    <script type="text/javascript">

    winReport=window.open('','winReport','width=900,height=500,left=50,top=100,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=0,titlebar=0');
    winReport.document.write('<html>');
    winReport.document.write('<body>');
    winReport.document.write('<table>');
    winReport.document.write((document.all.test.innerHTML));
    winReport.document.write('</table>');
    winReport.document.write('</body>');
    winReport.document.write('</html>');
    </script>
    </table>

    </body>
    </html>
     
    IveCal, Apr 2, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RJN
    Replies:
    1
    Views:
    8,746
    Patrik Löwendahl [C# MVP]
    Oct 10, 2004
  2. hazz
    Replies:
    6
    Views:
    49,627
    SkyUCHC
    Jun 9, 2010
  3. Gordon
    Replies:
    3
    Views:
    305
    Steven Burn
    Apr 16, 2004
  4. PC HUA
    Replies:
    2
    Views:
    416
    PC HUA
    May 19, 2004
  5. Replies:
    1
    Views:
    237
Loading...

Share This Page