|
I have a shopping cart site. I am storing products choosing in the session. How can i help me to capture event when user clicks the Close button (X button on the right top) to exit the Browser.
Thank in advance
vtkiet05
|
|
|
|
|
You can use onunload event of javascript. Something like this
Good Luck.
|
|
|
|
|
Thank you for reply. Your code will always display message whenever the page closed. That mean user has still not close Browser, they click other items on page the message display too.
Actually, I only confirm to user if they clicked Close Button (X buton on the right top )
Thank all your help
vtkiet05
-- modified at 0:33 Wednesday 4th July, 2007
|
|
|
|
|
>>Thank for your reply, Could you test the case which you link to other page?
>>I think that the message will displays. I don't want to display a message >>this case. I would like to display a message if user clicked Close Button (X >>button on the right top)
>>Thank all your helps
chk it out. hope it would help..
<code>
<!-- Warning if user is exitting Browser -->
<script type="text/javascript">
var UNLOAD_MSG = "You will lose any unsaved changes!";
var IGNORE_UNLOAD = true;
function doBeforeUnload()
{
if(IGNORE_UNLOAD) return; // Let the page unload
if(window.event)
window.event.returnValue = UNLOAD_MSG; // IE
else
return UNLOAD_MSG; // FX
}
if(window.body)
window.body.onbeforeunload = doBeforeUnload; // IE
else
window.onbeforeunload = doBeforeUnload; // FX
</script>
<!-- Check if user has shopped product -->
<script type="text/javascript">
function CheckOrder(isChanges)
{
IGNORE_UNLOAD = isChanges;
}
</script>
<body onload="CheckOrder(false);">
<form>
<!-- .....-->
<a href="http://michaelsync.net" onclick="CheckOrder(true);">mike</a>
</form>
</body>
</code>
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hello,
I am stating to learn how to make the crystal report. Using the report expert, I followed the wizard on how to make the crystal report. I used the standard format for me to be able to have the report and a chart.
Is it possible to only have the chart to show in my report? How? Can you give me a little tutorial?
Thank you very much in advance.
|
|
|
|
|
I have a code:
var UNLOAD_MSG = "You will lose any unsaved changes!";
var IGNORE_UNLOAD = true;
function doBeforeUnload()
{
if(IGNORE_UNLOAD) return; // Let the page unload
if(window.event)
window.event.returnValue = UNLOAD_MSG; // IE
else
return UNLOAD_MSG; // FX
}
if(window.body)
window.body.onbeforeunload = doBeforeUnload; // IE
else
window.onbeforeunload = doBeforeUnload; // FX
function CheckOrder(isChanges)
{
IGNORE_UNLOAD = isChanges;
}
The code above will confirm user whenever they try to exit a page if value of GetStatus() function is 'false'.
Actually problem the user has still not exit browser, they link to other pages
in the website but they always receive the message "You will lose any unsaved changes!". So I only want display a message when user is closing the Browser (Click "X" button).
Thank in advance.
vtkiet05
|
|
|
|
|
I dont think it can be done like that ..
all you can do is that you may need to set the statas "IGNORE_UNLOAD" to true manually in each and every click event of "A" tags.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Thanks Michael for your reply.
My exactly problem here is that I can't catch exactly the event when I click X button to close a browser. I tried to use unload event, but the big issue happened. Closing a browser and linking to other page are unload event, so the message always displays when i do both actions. I really want to catch the closing browser event(click on X button) only. Please send me any your solutions.
Thanks for all help.
vtkiet05
|
|
|
|
|
try "onunload" event of body..
I hav tested ur sample. it shows the msg when i click "x" button of your browser..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Thank for your reply, Could you test the case which you link to other page?
I think that the message will displays. I don't want to display a message this case. I would like to display a message if user clicked Close Button (X button on the right top)
Thank all your helps
vtkiet05
|
|
|
|
|
vtkiet05@hotmail.com wrote: I don't want to display a message this case. I would like to display a message if user clicked Close Button
What do you want to do ? Display confirmation message when user closing browser window ?
|
|
|
|
|
Yes,
Can you help me do that? I can display confirmation message when user closing browser window now. But if i link to other page, the message also displays.
Could you help me display confirmation message when user closing browser window?
Thank in advance
vtkiet05
|
|
|
|
|
>>Thank for your reply, Could you test the case which you link to other page?
>>I think that the message will displays. I don't want to display a message >>this case. I would like to display a message if user clicked Close Button (X >>button on the right top)
>>Thank all your helps
chk it out. hope it would help..
<code>
<!-- Warning if user is exitting Browser -->
<script type="text/javascript">
var UNLOAD_MSG = "You will lose any unsaved changes!";
var IGNORE_UNLOAD = true;
function doBeforeUnload()
{
if(IGNORE_UNLOAD) return; // Let the page unload
if(window.event)
window.event.returnValue = UNLOAD_MSG; // IE
else
return UNLOAD_MSG; // FX
}
if(window.body)
window.body.onbeforeunload = doBeforeUnload; // IE
else
window.onbeforeunload = doBeforeUnload; // FX
</script>
<!-- Check if user has shopped product -->
<script type="text/javascript">
function CheckOrder(isChanges)
{
IGNORE_UNLOAD = isChanges;
}
</script>
<body onload="CheckOrder(false);">
<form>
<!-- .....-->
<a href="http://michaelsync.net" onclick="CheckOrder(true);">mike</a>
</form>
</body>
</code>
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Very good. Thank you very much!!!
vtkiet05
|
|
|
|
|
I’m USING VB 2005 to write web forms (ASP.NET). In the tutorial it tells me to display the page in design view and then select DOCUMENT from the object list box at the top of the property window, then find the DefaultClientScript property and change it to VBScript. The problem being is that I can not find this property.
Help please, as I'm new to the ASP.NET environment.
Regards
Graeme Guildford.
I am always greteful for any help!
|
|
|
|
|
DefaultClientScript Property
http://msdn2.microsoft.com/en-us/library/7y9x7bh2(VS.80).aspx
How to: Set the DefaultClientScript Property of a Web Page
http://msdn2.microsoft.com/en-us/library/5y06x9d7(VS.80).aspx
if you dont find it then just put this line in ur page
<br />
<meta content="text/VBScript" http-equiv="content-script-type" /><br />
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Than you so much. I did rate your message and I am so grateful for your help. This is my first time with ASP.NET.
That line of code you wrote, where in the page is it inserted?
Thanks again
Graeme
I am always greteful for any help!
|
|
|
|
|
>>where in the page is it inserted?
put it between HEAD HTML tag of your page..
>>I did rate your message
Thanks a lot. Graeme
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Michael
Thank you very much. It worked a treat!!!!
Like I said this is the first time I've ventured into ASP.NET using VB 2005. The text book I'm studying from mis-lead me to changing the DefaultClientScript through the DOCUMENT property window, where I couldn't find the DefaultClientScript property. I did notice that one other programmer had the same problem where the BETA version of ASP.NET 2.0 had the property and the later release didn't.
Thanks again.
Regards
Graeme
I am always greteful for any help!
|
|
|
|
|
Hi all
Is there anyway in which i can ensure that when a user selects a textbox, that the enter button is automatically set to the button which inputs the textboxes text. Because after inputting into the textbox i do not want the user to have to manually click on a button to input the value.
Thanks or any help in this regard...
Devin
|
|
|
|
|
here is it how it works in ASP.NET:
When you press enter on a webform, the very first Button will fire click event. If you really want with some other button, you will have to manupulate on if(!IsPostBack) on page load.
Cheers
|
|
|
|
|
You can use the focus() funcxtion on the event of the textbox....
like ontextchange write a javascript and set focus on the button of your choice...
I was born dumb!!
Programming made me laugh !!!
--sid--
|
|
|
|
|
Actually, there are ways.... (there is always a way...)
This is how I solved it - my page has two textboxes, one for login and one for search, and two submit buttone - one for each - but like you I wanted the user to to be able to hit ENTER and have the "right" submit made...
This method is not foolproof, but works well enough and on all PC platforms I've tried and some but not all Mac OS's... (but that's Macs for you...)
Tweak it suit, obviously, but this is it cut down it's bones:
OK... login and search, and their buttons:
Member login:
<asp:TextBox id="txtLogin" runat="server" />
Password:
<asp:TextBox id="txtPwd" runat="server" TextMode="Password" />
<asp:LinkButton runat="server" ID="lbGo" OnClick="SubmitLogin" Text="Go"></asp:LinkButton>
Search:
<asp:TextBox id="txtSiteSearch" runat="server" ></asp:TextBox>
<asp:LinkButton runat="server" ID="lbSearch" OnClick="SiteSearch" Text="Go"></asp:LinkButton>
and some Javascript for the head of your page:
<script language="javascript">
function login13(e) {
if (e.keyCode==13) { __doPostBack('lfLogin$lbGo',''); }
}
function search13(e) {
if (e.keyCode==13) { __doPostBack('lfLogin$lbSearch',''); }
}
</script>
and in your code-behind:
Private Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
txtPwd.Attributes.Add("onkeyup", "return login13(event)")
txtSiteSearch.Attributes.Add("onkeyup", "return search13(event)")
End If
End Sub
Clearly you'll need to change both the javascript adn the code-behind to suit your controls' ID's... if you're not sure about the javascript __doPostBack arguments (NB the double-underscore) then run your page and look at the source as rendered in your browser and take the names from there...
Good luck....
Fred
|
|
|
|
|
Thanks very much all.. Will give it a try and post back should i encounter any difficulties.
Cheers
Dev
|
|
|
|
|
Hi experts
Is there a way to know what button was click within a form?
Here is my code:
<script language="javascript" type="text/javascript">
function Form1_onSubmit() {
alert("button clicked")
}
</script>
...
<form id="Form1" runat="server" onsubmit="return Form1_onSubmit()">
...
|
|
|
|