Random Snippets

  • Home
  • Sequence analysis blog
  • About
  • Categories
    • javascript
    • mysql
    • php
  • Subscribe via RSS

The dangers of embedding the notorious “void(0)” JavaScript code in the href attribute of the “a” tag

April 8th, 2009  |  by Knix  |  published in javascript

I recent ran into an interesting IE bug involving the following bit of html code:

<a href="javascript: void(0);" onclick="dosomething();">click me</a>

I honestly did not write this one but I will leave names out of this to protect the innocent =)
The void(0) JavaScript code is usually used to prevent loading or reloading of the page when the user [...]

How to find and access parent nodes via JavaScript

June 26th, 2008  |  by Knix  |  published in javascript

function findParentNode(parentName, childObj) {
var testObj = childObj.parentNode;
var count = 1;
while(testObj.getAttribute(’name’) != parentName) {
alert(’My name is ‘ + testObj.getAttribute(’name’) + ‘. Let\’s try moving up one level to see what we get.’);
[...]

How to dynamically add content to a div and store the content to a cookie via JavaScript

April 14th, 2008  |  by Knix  |  published in javascript

function addContent(divName, content) {
document.getElementById(divName).innerHTML = content;
}
function setCookie(c_name,value,expiredays) {
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ “=” +escape(value)+((expiredays==null) ? “” : “;expires=”+exdate.toGMTString());
}
function getCookie(c_name) {
if (document.cookie.length>0) {
c_start=document.cookie.indexOf(c_name + “=”);
[...]

Recent Posts

  • Sorting 2D associative arrays in PHP
  • About
  • Dynamic or on-the-fly percentage calculations with JavaScript
  • Sequence analysis blog
  • The dangers of embedding the notorious “void(0)” JavaScript code in the href attribute of the “a” tag

Recent Comments

  • drei on Simulate a button click via JavaScript
  • Subhee on How to count values with MySQL queries
  • Russell Day on How to hide, show, or toggle your div
  • phi on How to hide, show, or toggle your div
  • bornholy on How to hide, show, or toggle your div

Archives

Categories

  • javascript
  • mysql
  • php

Tag Cloud

add addition and subtraction calculator checkboxes checkEmail content demo demo content div id document getelementbyid dynamic Dynamically dynamic content emailRegEx find form getElementById html javascript input buttons input object input text javascript javascript code javascript demo javascript email javascript function javascript functions loop through menu multiplication mysql mysql query onClick onclick event query regex remove removeChild removeElement replace simulate styling valid email address verification verifyEmail


©2010 Random Snippets