S
souporpower
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="javascript" type="text/javascript">
$(document).ready(function(){ $('.mylink').click(function()
{ $.jPrintArea('#tabularData') }); });
jQuery.jPrintArea=function(el)
{
alert("hello");
var iframe=document.createElement('IFRAME');
var doc=null;
$(iframe).attr('style','position:absolute;width:0px;height:
0px;left:-500px;top:-500px;');
document.body.appendChild(iframe);
doc=iframe.contentWindow.document;
var links=window.document.getElementsByTagName('link');
for(var i=0;i<links.length;i++)
if(links.rel.toLowerCase()=='stylesheet')
doc.write('<link type="text/css" rel="stylesheet" href="'+links.href
+'"></link>');
doc.write('<div class="'+$(el).attr("class")+'">'+$(el).html()+'</
div>');
doc.close();
iframe.contentWindow.focus();
iframe.contentWindow.print();
alert('Printing...');
//wait(1);
document.body.removeChild(iframe);
}
</script>
</head>
<body>
<div id="tabularData">
<a href="#" class="mylink" name="mylink">Print 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.
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="javascript" type="text/javascript">
$(document).ready(function(){ $('.mylink').click(function()
{ $.jPrintArea('#tabularData') }); });
jQuery.jPrintArea=function(el)
{
alert("hello");
var iframe=document.createElement('IFRAME');
var doc=null;
$(iframe).attr('style','position:absolute;width:0px;height:
0px;left:-500px;top:-500px;');
document.body.appendChild(iframe);
doc=iframe.contentWindow.document;
var links=window.document.getElementsByTagName('link');
for(var i=0;i<links.length;i++)
if(links.rel.toLowerCase()=='stylesheet')
doc.write('<link type="text/css" rel="stylesheet" href="'+links.href
+'"></link>');
doc.write('<div class="'+$(el).attr("class")+'">'+$(el).html()+'</
div>');
doc.close();
iframe.contentWindow.focus();
iframe.contentWindow.print();
alert('Printing...');
//wait(1);
document.body.removeChild(iframe);
}
</script>
</head>
<body>
<div id="tabularData">
<a href="#" class="mylink" name="mylink">Print 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.