简体   繁体   中英

When i include jquery.js in markup other javascript functions in the page are not firing

I have a large asp.net 2.0 application. In the current page i have one

<head id="head1" runat="server"> with some meta information and the original developer has written all Javascript functions in the <body> tag. Now i want to implement

$(document).ready(function load()
    // My code 
});

and when i include jquery-1.8.3.js in my head/body tag , the other javascript functions are not working properly. what could i do to solve this?

 <head id="Head1" runat="server">`
 <script language="javascript" type="text/javascript" src="JScript/jquery-1.8.3.js"/>`
 <meta http-equiv="Expires" content="0" />
 <meta http-equiv="Cache-Control" content="no-cache" />
 <meta http-equiv="Pragma" content="no-cache" />
 <title>HMS</title>
 <link href="Css/MyStyleSheet.css" rel="stylesheet" type="text/css" />
 </head>

Body

<body>
<script language="javascript" type="text/javascript" src="JScript/MediReckonerJscript.js">
</script>
//some javascript functions here that are not firing since i added jquery reference in the head section. if that is removed this function works well.

My script in body that usesjQuery Library.

<script type="text/javascript" language="javascript"> 
//This is my script in the <body> tag.
jQuery.noConflict();
$(document).ready(function load() {
  var iFrame = $('#PageFrame');

iFrame.bind('load', function() { //binds the event
    alert('iFrame Reloaded');
});
});
</script>

Perhaps this could be the version problem please check with some lower version of the same library also you can use jQuery.noConflict(); for jQuery is conflicting OR $.noConflict(); if $ is conflicting.

Use noConflict() like this

 <script type="text/javascript" language="javascript"> 
//This is my script in the <body> tag.
var j = jQuery.noConflict();
j(document).ready(function load() {
  var iFrame = j('#PageFrame');

iFrame.bind('load', function() { //binds the event
    alert('iFrame Reloaded');
});
});
</script>

If you have other libraries in your page add this.

jQuery.noConflict();

Libraries like prototype use the same '$' used by jQuery and so, they conflict.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM