Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
need help with close tab script
Old 08-13-2010, 02:40 PM need help with close tab script
ZoC
Skilled Talker

Posts: 68
Trades: 0
hello there, this is the script

HTML Code:
<html>

<script type="text/javascript">
 var bEdited=new Boolean();
  
 function UnLoadWindow() {
  if (!(bEdited)) {
   return
  }
  return 'You are sure want to exit from this website?'
 }
 
 window.onbeforeunload = UnLoadWindow;
</script>

<body>

<a href="?test=test">test</a>

</body>
</html>
this script is working but the problem is when someone click "test" link on my website all time is show that message, how i can make this to show just if the user close website (tab/browser)

thanks for the help
ZoC is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-13-2010, 02:53 PM Re: need help with close tab script
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You can't.

OnBeforeUnload triggers on EVERY change of window.location
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-13-2010, 03:05 PM Re: need help with close tab script
ZoC
Skilled Talker

Posts: 68
Trades: 0
but can be another way to make this ? just if the user close tab/browser to show that message ? normaly i know need to be becouse i see before to some websites that script but i forget that websites
ZoC is offline
Reply With Quote
View Public Profile
 
Old 08-13-2010, 03:16 PM Re: need help with close tab script
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Add an prompt() dialog to the action for closing the tab instead of the OnBeforeUnload event.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to need help with close tab script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28138 seconds with 12 queries