• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

put javascript method in body tag and its not returning anything

 
Ranch Hand
Posts: 114
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here what actually i am doing is that I am catching the popup window close button event by placing a javascript method in <body> tag and this is working fine.
the problem i am facing is that when i write return statement inside the javascript code,its not returning to the previous page just returning to the root page.I am sure i missed something ..guys any idea..
these are my codes(testing it in IE8)



html page
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The term "root page" has no meaning. Please be more precise in describing your issue.

I suspect what you want is: return false;

Also, please make sure indentation is correct when posting code. The indentation in your posted code is horribly wonky.
 
Vas Miriyala
Ranch Hand
Posts: 114
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot for your reply and my apologies for that.well I tried as you said writing return false but it did not worked.The actual scenario is ,I have a page(parent page) with one button called popup,when user clicks on the pooup button,(the child page)the popup window will appear and the popup window contains a text field which is mandatory field.if the user clicks on a popup window close button without entering text in a textfied we need to display a alert message.
I am done up to the displaying the alert message,but when user clicks onthe ok button of alert message box its returning to the parent page,but i dont want to that happen,I need to show the popup window untill user enters the text.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code is not even close to being how onbeforeunload works. Look at some docs: https://developer.mozilla.org/en/DOM/window.onbeforeunload

Eric
 
Vas Miriyala
Ranch Hand
Posts: 114
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your Link and as you suggested I followed the code as it is in the link.then also i could not bale to do below are my codes


if i have writeen jusr "return null" then its also returning to the previous page.Is there anyway to make it work?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is NO WAY to prevent the user from not leaving the page. That is how a browser works. IF they press Ok, they will go to wherever the page is going to. If they push cancel, they will stay on the current page.

If you need to force input, than you SHOULD NOT use a pop up. Use a modal layer in the orgainl page. An example is jQuery UI dialog.

Eric
 
Vas Miriyala
Ranch Hand
Posts: 114
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot for your valuable replies.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic