Hello All
I am trying to activate a link using Jquery. Here is my code;
<html>
<head>
<script type="text/javascript" src="../../resources/js/
jquery-1.2.6.js"</script>
<script language="javas cript" type="text/javascript">
$(document).rea dy(function(){ $('.mylink').cl ick(function()
{ $.jPrintArea('# tabularData') }); });
jQuery.jPrintAr ea=function(el)
{
alert("hello");
var iframe=document .createElement( 'IFRAME');
var doc=null;
$(iframe).attr( 'style','positi on:absolute;wid th:0px;height:
0px;left:-500px;top:-500px;');
document.body.a ppendChild(ifra me);
doc=iframe.cont entWindow.docum ent;
var links=window.do cument.getEleme ntsByTagName('l ink');
for(var i=0;i<links.len gth;i++)
if(links[i].rel.toLowerCas e()=='styleshee t')
doc.write('<lin k type="text/css" rel="stylesheet " href="'+links[i].href
+'"></link>');
doc.write('<div class="'+$(el). attr("class")+' ">'+$(el).html( )+'</
div>');
doc.close();
iframe.contentW indow.focus();
iframe.contentW indow.print();
alert('Printing ...');
//wait(1);
document.body.r emoveChild(ifra me);
}
</script>
</head>
<body>
<div id="tabularData ">
<a href="#" class="mylink" name="mylink">P rint this Table</a>
</div>
</body>
</html>
When I click on the link I see nothing. I am expecting to see an
alert. Could someone please tell me where
I am going wrong?
Thanks for your help. Sorry I am unable to post the code on a web
site.
Comment