/    Sign up×
Community /Pin to ProfileBookmark

Hyperlinked Alert

Just a tip from me…I found a way to make an alert box from a hyperlink, via a function. I use it for a copyright notice….so could you. Here it is:::

[code]
<script language=”Javascript” type=”text/javascript”>
function copyright(){
alert(“COPYRIGHT (customize)”)
}
</script>

<a href=”javascript:copyright()”>Alert Box</a>
[/code]

And that is how you do it!!!

Isn’t that clever (and useful)?

Oddball

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@scottymacMay 04.2004 — it would be better as:&lt;script language="Javascript" type="text/javascript"&gt; function copyright() { alert("COPYRIGHT (customize)") } &lt;/script&gt;

&lt;a href="#" onclick="copyright();return false;"&gt;Alert Box&lt;/a&gt;
Copy linkTweet thisAlerts:
@OddballauthorMay 04.2004 — Well, yeah, but it't totally up to you.... ?
Copy linkTweet thisAlerts:
@scottymacMay 04.2004 — and if its just an alert, one doesn't need a function, but anyway its implemented is fine
Copy linkTweet thisAlerts:
@VladdyMay 04.2004 — [i]Originally posted by Oddball [/i]

[B]Just a tip from me...I found a way to make an alert box from a hyperlink, via a function. I use it for a copyright notice....so could you. Here it is:::



<i>
</i>&lt;script language="Javascript" type="text/javascript"&gt;
function copyright(){
alert("COPYRIGHT (customize)")
}
&lt;/script&gt;

&lt;a href="javascript:copyright()"&gt;Alert Box&lt;/a&gt;


And that is how you do it!!!

Isn't that clever (and useful)?

Oddball [/B][/QUOTE]

Neither clever, nor useful, nor the way of doing it.

- language attribute has been deprecated for 5 years now

- no such thing as javascript: protocol

- if you need to attach script to a link you use onclick event.

- since in your example the link does not point to a resource, there is no need to use anchor attribute for envoking your alert - span would suffice:

<span onclick="someFunction()">Click to run a script</span>

:rolleyes:
Copy linkTweet thisAlerts:
@OddballauthorMay 04.2004 — Thanks. That really helps. I think Ill leave here now. Well done, mate.
Copy linkTweet thisAlerts:
@scottymacMay 04.2004 — however, building on it could use the purpose of onclick="return confirm('Go?')" which would require the anchor tag
×

Success!

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

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

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