/    Sign up×
Community /Pin to ProfileBookmark

Reset div when navigating away from page

Hi Guys

I have a div tag which shows up when an unknown error occurs with an ajax request. What I want to do is when I click on any of the menu links to navigate away from the page the div tag should disappear.

The current method I am using is a call to a function which resets the tag. The only problem with this method is that I have to call it on every menu link so that [B]“if”[/B] the div is active it is then reset. Is there a more efficient of doing this?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@DokSep 18.2008 — Depends on what you mean by navigatin away. If you are actually leaving/reloading the entire page you can use the onbeforeunload event - but that seems rather pointless as you are in fact destroying the entire page so the need for hiding the div is gone anyway.

If you mean that you are replacing some content through using Ajax without actually leaving/reloading the page then I it depends on your design. If you have some standard function for doing the Ajax calls you can have the function for hiding the div there.
Copy linkTweet thisAlerts:
@ShaolinauthorSep 18.2008 — Mine is the latter, I use ajax to replace content. Can you give me some example code ?
×

Success!

Help @Shaolin spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...