/    Sign up×
Community /Pin to ProfileBookmark

not triggered by a link

Is there any way to code this? (Everything I come up with seems way too complicated for the task and leads me in circles.)

If (this function was not triggered by clicking a link) {
do this
}

Thanks!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@demoMar 10.2004 — someone will probably say this is only IE applicable but what the hell, it gives you a start

<i>
</i>&lt;HTML&gt;
&lt;HEAD&gt;
&lt;META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"&gt;
&lt;TITLE&gt;&lt;/TITLE&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;SCRIPT&gt;

function doIt(){
if(event.srcElement.tagName!="A"){
alert("Hmm, this was not triggered by link!")
}
}

&lt;/SCRIPT&gt;
&lt;a href="#" onclick="doIt(); return false;"&gt;Click Here&lt;/a&gt;
&lt;P&gt;
&lt;input type=button onclick="doIt()" value="Click Me"&gt;

&lt;/BODY&gt;
&lt;/HTML&gt;


cheers
×

Success!

Help @jazzyjade 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...