We would like to know how to create anchor href automatic link.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
var catagor;
function foo(){<!--from w ww . jav a 2s . c o m-->
catagor = 'worldru';
document.getElementById('printableArea').innerHTML = "<a href='javascript:void(0);' onClick='changePage(\"" + catagor + "\")'> CLICK HERE</a>";
}
function changePage(url){
console.log('Parameter passed: ' + url);
}
</script>
</head>
<body>
<body onload="foo()">
<div id="printableArea"></div>
</body>
</body>
</html>
The code above is rendered as follows: