Many people contemplate suicide, but often don't mean it. In some cases, people actually undergo number of events that pressure the person to take suicide as an alternate option, rather than bearing such pain. As a friend, or at least as a human, one must take some sort of measure to help them.
The thing one must to do is to talk to them. The first thing is to ask whether there is something wrong, and if it can be helped. If they say no, but it seems like there is a problem, persist. When they tell their problems, listen to them in detail, in order to help them. Ask them about their problems, and how they can solve them, one at a time. Ask if there is way for others to help them with their problem, as more people can offer more help than one person. Ambivalence is natural for the victim and for the friend, but indifference towards such a situation will only make the problem worse. Reassure them throughout the process, when trying to get help.
If the problem is really serious, then, one must keep them under surveillance, as in monitor them for problems like bullying, negative emotions, but most importantly, tendencies of suicide. One must also involve as many trustworthy people to help. One can also ask other people, usually close friends, if they know information, and what other problems that the person had not admitted that were too personal, or confidential.
One must refer the person to a counsellor, a psychiatrist or even a doctor if a problem is medically related. Experienced counsellor can help as they can offer solutions to problems that the person has. A psychiatrist may be necessary if it is related to a mental illness, or if the problem is a depressive disorder or a manic depression. A doctor may refer to other people who can help, if a counsellor or a psychiatrist is not known or present in the local area. If the person decides not to go, ask their parents or guardians to help in the decision to go. At this point, one cannot simply do nothing and ignore the problem.
If, even after helping them, they attempt suicide within your presence, if you can, administer first aid. Call for help and emergency medical services, and reassure them as much as possible.
If you yourself are contemplating suicide, you must talk to someone about it. Counsellors may be the best person to talk to, as they will not tell anyone, and usually will not interrupt you or tell you that you aren't thinking properly, unless you trust someone else, such as a close friend, or relative.
The best thing to do is to look for help. As good as the internet might be, a person may be better as they can give personal help, rather than the general help that the internet offers. A doctor can refer to various people who can help with your situation.
Remember, there is always someone you can talk to, and suicide isn't the only option.