帮助Jquery:无法注册就绪函数 [英] Help Jquery: unable to register a ready function

查看:41
本文介绍了帮助Jquery:无法注册就绪函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



Hello All


我正在尝试使用Jquery激活链接。这是我的代码;


< html>

< head>

< script type =" text /的javascript" src =" ../../ resources / js /

jquery-1.2.6.js"< / script>


< script语言= QUOT; 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:0p x; 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 [i] .rel.toLowerCase()==''stylesheet'')


doc.write(''< link type =" text / css" rel =" stylesheet" href ="''+ links [i] .href

+''">&l t; / link>'');


doc.write(''< div class ="''+ $(el).attr(" class")+ ''">''+ $(el).html()+''< /

div>'');


doc .close();


iframe.contentWindow.focus();


iframe.contentWindow.print();


alert(''打印......'');


//等待(1);


document.body.removeChild(iframe);


}

< / script>

< / head>

< body>

< div id =" tabularData">

< a href ="#"类= QUOT; myLink的" name =" mylink">打印此表< / a>

< / div>

< / body>

< ; / html>


当我点击链接时,我什么也看不见。我期待看到一个

警报。有人可以告诉我在哪里

我错了吗?


感谢您的帮助。抱歉,我无法在网站上发布代码

网站。


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:0p x;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[i].rel.toLowerCase()==''stylesheet'')

doc.write(''<link type="text/css" rel="stylesheet" href="''+links[i].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.

推荐答案

(文档)。 ready(function(){
(document).ready(function(){


(''。mylink'')。click(function()

{
(''.mylink'').click(function()
{


.jPrintArea(''#tabularData'')});});


jQuery.jPrintArea = function(el)

{

alert(" hello");


var iframe = document.createElement(''IFRAME'');


var doc = null;

.jPrintArea(''#tabularData'') }); });

jQuery.jPrintArea=function(el)
{
alert("hello");

var iframe=document.createElement(''IFRAME'');

var doc=null;


这篇关于帮助Jquery:无法注册就绪函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆