.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

need help on Window unload using javascript

Posted By:      Posted Date: October 15, 2010    Points: 0   Category :ASP.Net

Hi everyone,

I need to sent mail to my customers while they close the browser tab of my site for particular page...

Its working fine, but the problem is when the users navigate from the particular page, mail is sending....

I need to sent mail only the browser tab is closed and not on navigating to some other pages....

Its very urgent....Please any one come forward to help.......

Waiting for your replay.......


View Complete Post

More Related Resource Links

way of calling "javascript function of parent window from child window."

The article way of calling "javascript function of parent window from child window." was added by raja.s on Sunday, June 06, 2010.

Hi,Here i am going to explain how to call the javascript function of a parent window from the child window(pop-Up).Some may know before reading this post.Parent Java Script Function:script language="Javascript" type="text/javascript">

Browser window is opening up on the second click with javascript code



I am trying to set a javascript code to open up a new browser window with this URL that exists like shown below.

On the first click nothing happens but on the second click the browser window is opening up.


How is it possible to make it open up on the first click ?

                                <asp:ImageButton ID="ImageButton3" runat="server" Height="84px" 
                                    ImageUrl="~/images/1.jpg" Width="165px" 
                                    onclick="ImageButton3_Click" />

    protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
        String openURL = "javascript:window.open('" + "Folder1/testing.aspx" + "');return false;";
        ImageButton3.OnClientClick = openURL;


Closing Javascript Modal dialog window after server side event processing


Hello Friends..

Please tell me how to close Javascript ModelDoalog Window.. after Server Side event Processing .

Basically i want close window in  finally Block After sucessfulll Updation.

AMit..... InnocentInnocentInnocentInnocentInnocentInnocentInnocent

How to prevent Javascript window to steal focus

Hi,I have made an asp.net web application in which i open a javascript window for 4 seconds at regular interval . The problem is that when window opens it steals focus from current application. For example when application is running in background or is minimized and i am typing in word/Excel or outlook, the window pops up and steals the input focus.I want to popup window in some way that it never steal focus from some other application, just like msn or gtalk notification when someone sign in/out.Please suggest how it can be done ? Thanks

Javascript required to get a pop up window from new form.

Hello Team, Any help regarding this would be helpful. I have a new form. In that form when i go to the first field...it should open up a pop up window which would have a note in that. How is this possible. I think through javascript this can be possible. So please help me. Thanks in advance.

Closing window in javascript without confirmation

Hello! I need to open a browser window without Toolbars, Status bar and Explorer bars (this means no back, refresh, ... buttons, no histiry, no nothing visible in this browser window). This is what I do: from normal browser window I open new window with all the properties I need and than I close the first window: <body>     <script type="text/javascript">  window.open('login.aspx','','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,                        left=0px, top=0px,width=1024, height=768');  window.close();     </script> </body> This would be OK if the first window would just close, but it doesn't. I get the confirmation window with this text: The Web page you are viewing is trying to close the window. Do you want to close this window? I don't want user to have to close the window manually. Can somebody please tell me how to close browser window without the confirmation popup? Thnx in advanced, dvale

How to Get PrintPreview window using javascript in Asp.Net

Hi All,I am using Window.Print() method to print a webpage. When I am click print button in my page. Print dailog window is opening there I have the options only to print the form or cancle. Before print I want to view the content how it is going to print. In browser File menu we have Print Preview. I want to give same feature when user click on Print button. How to open print preview window using java script?Thanks in advance

ASP.Net Page Validation and Window Unload

I am getting some weird issue on my asp.net page.Here is the scenario:I have a asp.net page with a textbox (ctrl#1) and a dropdown control (ctrl#2). Each control have their CausesValidation and AutoPostBack set to true. I have another dropdown control (ctrl#3) on the same page which allows the user to navigate to some other page. I have added an alert message for the user (on window.onbeforeunload event) to warn the user of any unsaved changes on the page. User can choose to stay on the current page by clicking Cancel.So far so good... All works fine when the data is changed on the page  and user tries to navigate away from the current page using the above dropdown control (ctrl#3). The window.onbeforeunload fires and user gets the alert message. Happy user.Now comes the issue....When there is any invalid data on the page and the asp.net validation has fired, now, when the user tries to navigate away from the current page, he does not get any alert. It seems as if the window.onbeforeunload does not fire in this case when there is invalid data on page. I am not sure why this is happening!Can someone please share some thoughts and/or suggest a solution please?

Javascript Unload event

Hi,   Just a quick general question about javascript. Is it possible for the browser unload event not to fire sometimes? I have a webmethod that fires at the time the user closes , presses back, presses forward or refreshes the asp.net page.   Any known bugs in browsers that may prevent unload events from firing sometimes? I would like to hear somebody's opinion on this.    Thanks

Open New Window Using Javascript

Using SSRS 2008. I have a main report where the user clicks on the KPI field and I want to open a new window and go to a detail report and pass parameters from the main report to the detail report. The following javascript will do that but when the KPI has "&" in it I get the following error. In this example the KPI field clicked on had "Headcount Imp & Ops" in it. Keep in mind the KPI field could have the "&" at anytime. Anyway around this? I appreciate any help. Error = The path of the item '/Test/DetailRpt, Imp' is not valid. The full path must be less than 260 characters long; other restrictions apply. If the report server is in native mode, the path must start with slash. (rsInvalidItemPath) Code. = "javascript:void(window.open('http://velma.fmr.com/ReportServer/Pages/ReportViewer.aspx?%2fSPARS%2fDetailRpt&rs:Command=Render&rc:Parameters=true&RptMonth=" & Parameters!RptMonth.value & "&Reports=" & Parameters!Reports.value & "&ID=" & Fields!ID.Value & "&Alias=" & Fields!KPI.Value & "&BD=" & Parameters!BD.Value & "&BD=" & Parameters!ED.Value &" ','_blank','width=875, height=400, top=75, left=35, toolbar=1, menubar=1, location=1, status=1, scrollbars=1, resizable=1'))"

opening new window from code behind using javascript



I am trying to open new window when i click on a button using javascript

Page.ClientScript.RegisterStartupScript(this.GetType(), "openwindow", "window.open('WebForm2.aspx','','height=200,width=300');", true);

this is the code i am using.

But the problem is it postsback whole page.

Can some body tell me how i can open new window without posting back the page.



javascript window.history.back() issue with Modal popup extender



I have a asp.net page that has a list of items. When one of the items from the list is clicked a details page is displayed. This details page has a link button to show a popup for history of the item. The details page also has a button with text 'Back'.  The back button has onclick event set to  "javascript:window.history.back();".

This back button works fine and goes back to the first page. However when the user is on the second page and opens the pop up by clicking on the link button, the back button stop working and displays Webpage has expired message.

Any help would be appreciated.




javascript alert window when dropdown field is selected,



is there a way..where an alert window prompts up to remind the user to select a checkbox when one field in dropdown is selected..for example

there is a dropdown field(Status)  which contains (Tobe confirmed, confirmed and rejected ), when confirmed is chosen..an alert window prompts up reminding the user to select a checkbox(send email) - Yes or No. It is not compulsory for the user to select the checkbox, but if Yes is chosen, the workflow will send an email

Problem with a Javascript Popup Window Minimizing itself


I am new to Javascript.  I have seen other posts about this, but I have not been able to resolve my problem. I have a WebPage that allows a user to click a LinkButton. When the LinkButton is clicked. I execute the following Javascript code after registering the ClientScriptBlock:

<script language='Javascript'>
PopupWindow = window.open('StandardImageLookupPage.aspx','PopupWindow');
PopupWindow.resizeTo(screen.width, screen.height);

No matter what I do the popup window comes up for a brief second and then minimizes itself. I prefer that the window stays maximized.

I am stumped. Any help would be much appreciated.

ps. I am not sure if this makes a difference, but the WebForm that calls this javascript is a user control.

javascript window.open problem



i have a page(A page) which has a linkbutton on it and i have added the following onattribute method which opens a new popup window(B page)


"onclick", "window.open('" & likeLink & "','newwindow','location=no,toolbar=no,directories=no,menubar=no,width=300,height=400,resizable=yes,scrollbars=yes,top=200,left=250,status=no'); return false;")

now on page B which has poped up there are some links

here is

javascript popup window...


hi to all,

i want to open a popup window, when click a link in the gridview.

i done this.

my problem is, the popup will be model popup, user can't do any in the page before closing the popup window.

and also i have a button in my popup window, when the button clicked,

i want to update some values to DB, popup window close and also the main page need to refresh (then only the updates load in grid.)

how to solve this.

thanks in advance

Javascript Confirm , return statements on window.beforeUnload


Hi all,
I'm using javascript function window.onbeforeunload to display a message to the user before he exits the page.
This javascript is calling a server method( ASP.NET and Vb.net) , if the user decides to exit the page. Else do nothing.
I'm having trouble with javascript(newbie here).The trouble is:
Originally while exiting the page, i used to do anything.This is how i used to alert the user
  if (showUnloadMessage)
return('You have attempted to leave this page.If you have made any changes to the fields without clicking Submit button,This Data will be saved as This Month Report.Are you sure you want to exit the page?');

But now i have to call a server side script based on user answer.If he decides to Quit, i have call server side function.I have written the code as below, but It gives the the message" you have attempted", and then also gives confrim message.I dont want that confirm message. I want only The "you have attempted to leave" message.If i remove the confirm () , then how do i alert the user. Where do i put these retun statemets.
Please help me correct the following javascript. The rerun statements are soo confusing to me..!!!
Thanks again


Code snippet:

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend