SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    function expected error when window is closed

    Hi All,

    i am getting the following error when i try to close a window opened through client side before print dialog appears.
    Error: function expected

    I am opening a window and print dialog simultaneously, print dialog is taking few seconds to open after the window. before the print dialog is opened when i close the window i am getting the error.
    below is my code,

    function OnClick() {

    var a = window.open('', '', 'width=300,height=300');
    a.document.open("text/html");

    a.document.close();
    a.print();
    }


    <asp:Button ID="btn" runat="server" Text="Click" OnClientClick="OnClick()"/>


    Can any one please help me how to resolve this issue.

    Thanks you,

    Jai

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    onClick is already a javascript function, that *might* cause an issue.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you SpikeZ for your reply, even if i change the function name still its an issue. Issue is coming when i close the popup before print window is displayed.

  4. #4
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function OnClick() 
    {
    
                var a = window.open('', '', 'width=300,height=300');
                a.document.open("text/html");
                
                // presumably you're writing content here 
      
                a.document.close();
    
                if( !a.closed )
                  a.print();
    }
    Tab-indentation is a crime against humanity.

  5. #5
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Logic Ali, i tried as you mentioned above but no use, still i am getting error.

    Thank you once again.

  6. #6
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jayasimhak47 View Post
    Thank you Logic Ali, i tried as you mentioned above but no use, still i am getting error.

    Thank you once again.
    Where do you see this error message and what data are you writing to the window?
    Tab-indentation is a crime against humanity.

  7. #7
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Logic Ali View Post
    Where do you see this error message and what data are you writing to the window?
    in the popup we are loading some content to be printed.

  8. #8
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Error.png

    please find the error image attached.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •