如何将JQuery源的引用传递到主页的iframe中的子页面 [英] how to pass reference of JQuery source to child page in iframe from main page
本文介绍了如何将JQuery源的引用传递到主页的iframe中的子页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个主页面,其中有一个iframe。在这个iframe中我添加了一个子页面。
示例代码如下。
< html xmlns = http:// www。 w3.org/1999/xhtml\">
< head runat = 服务器 >
< title > < / title >
< script 类型 = text / javascript src = Scripts / jquery- 1.4.1.min.js > < / script >
< script type = text / javascript >
$(document).ready (function(){
alert('hi from main');
});
< / script >
< / head >
< body > ;
< 表格 id = form1 runat = server >
< div >
& lt; iframe id = iframe1 runat = server src = Child。 aspx > < / iframe >
< / div >
< /表格 >
< / body >
< / html >
请注意,我在此处添加了Jquery参考。
现在我的子页面的代码如下:
< html xmlns = http://www.w3.org/1999/xhtml >
< span class =code-keyword>< head runat = server >
< title > < / title >
< script 类型 = text / javascript >
$(document).ready(function(){
alert('hi from child' );
});
< / script >
< / head >
< body > ;
< 表格 id = form1 runat = server >
< div >
< < /秒pan> / div >
< / form >
< / body >
< / html >
我的问题是
为什么在主页中显示警报,而在子页面中显示$未定义。
如何在子页面中不添加以下行的情况下将JQuery源引用传递给子页面
< script type = text / javascript src = Scripts / jquery-1.4.1.min.js > < / script >
解决方案
(文件).ready(function(){
alert('hi来自main');
});
< / script >
< / head >
< body > ;
< 表格 id = form1 runat = server >
< div >
& lt; iframe id = iframe1 runat = server src = Child。 aspx > < / iframe >
< / div >
< /表格 >
< / body >
< / html >
请注意,我在此处添加了Jquery参考。
现在我的子页面的代码如下:
< html xmlns = http://www.w3.org/1999/xhtml >
< span class =code-keyword>< head runat = server >
< title > < / title >
< script 类型 = text / javascript >
(document).ready(function(){
alert ('来自孩子');
});
< / script >
< / head >
< body > ;
< 表格 id = form1 runat = server >
< div >
< < /秒pan> / div >
< / form >
< / body >
< / html >
我的问题是
为什么在主页中显示警报时,在子页面中显示
未定义。
如何在子页面中不添加以下行的情况下将JQuery源引用传递给子页面
< script type = text / javascript src = Scripts / jquery-1.4.1.min.js > < / script > 跨度>
I have a main page in which I have an iframe. Inside this iframe i am adding a child page.
Sample code as below.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
alert('hi from main');
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<iframe id="iframe1" runat="server" src="Child.aspx"></iframe>
</div>
</form>
</body>
</html>
Please note that I have added Jquery reference here.
Now my child page has code as below:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
$(document).ready(function () {
alert('hi from child');
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
My questions are
why alert in main is getting displayed while in child page it says $ is undefined.
How can I pass JQuery source reference to child page without adding below line in child page
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
解决方案
(document).ready(function () { alert('hi from main'); }); </script> </head> <body> <form id="form1" runat="server"> <div> <iframe id="iframe1" runat="server" src="Child.aspx"></iframe> </div> </form> </body> </html> Please note that I have added Jquery reference here. Now my child page has code as below: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript">
(document).ready(function () { alert('hi from child'); }); </script> </head> <body> <form id="form1" runat="server"> <div> </div> </form> </body> </html> My questions are why alert in main is getting displayed while in child page it says
is undefined. How can I pass JQuery source reference to child page without adding below line in child page <script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
这篇关于如何将JQuery源的引用传递到主页的iframe中的子页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文