'Click on link without the basic message

How to do that when you click on the link did not work event. Example:

HTML

<div><p onclick='location.href=/link_site'>message and link http://example.com/abcde</p></div>

I clicked http://example.com/abcde and working location.href, how to make when you press on the link to the event did not work location.href?



Solution 1:[1]

Unless you are working inside PHP (or other language?), you do not need the backslashes to escape the double-quotes.

Escaping tells the processor/server to read the next character as a literal entry instead of instruction code. (This is not a technical explanation).

In HTML5, you don't need single or double quotes, but it is good form to contain your information.

<div><p onclick='location.href=link_site'>message and link http://example.com/abcde</p></div>

Solution 2:[2]

No.For blocking click event or something like this,there are ideas called preventDefault and stopPropagation.You can search those names and read what do these mean.Here is a link of click events.maybe it can help you.

http://www.w3docs.com/learn-javascript/javascript-events.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kirk Powell
Solution 2 Hazarapet Tunanyan