/    Sign up×
Community /Pin to ProfileBookmark

Protect page from links

I am trying to figure out how I can keep my page from linking to a new page when I click on a link from an IM or email, etc. For example, I am working on a web based applicaton and I click on a link to go to ESPN.com. It takes me to espn straight from the application and I lose unsaved work. Any ideas? I tried calling a function from the onunload event and have tried several different attempts at blocking the link including the following different ideas:

location.replace(location.href);

location.href=’myapp.html’

history.go(-1);

However, my code does nothing. I do popup an alert to show that my method is being called but after the alert I get directed to espn. If I can click back in time on the browser, I am okay so I thought the above segments would do the trick but they do nothing. Thanks for any help!!!

Dan

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@RebelParkauthorJul 15.2003 — Also, does anyone know how I can edit my profile settings?

Long time reader, first time poster.
Copy linkTweet thisAlerts:
@jrlaughlinJul 15.2003 — Can you not just set the target of the link to open in a new window?

Like this.

<a href="http://espn.go.com" target="newWindow">ESPN</a>
Copy linkTweet thisAlerts:
@DaveSWJul 15.2003 — [i]Originally posted by RebelPark [/i]

[B]Also, does anyone know how I can edit my profile settings?



Long time reader, first time poster. [/B]
[/QUOTE]


try the 'user cp' button under web developer news at the top of the page.
×

Success!

Help @RebelPark 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.19,
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,
)...