Activate JQUERY Document ready function only on specific pages in global javascript file

peter liles 471 Reputation points

I have a drag and drop feature that is activated when particular page is open using the document method. As i understand it is fired every time on page load. I have now placed the code in a javascript file. The trouble is it will now load on all pages that access javascript file when i just want it to load when particular pages load, two?

var srcElement = '';

$(document).ready(function () {

ASP.NET Web Forms
ASP.NET Web Forms
A part of the ASP.NET web application framework that can be used to create ASP.NET web applications.
555 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Yijing Sun-MSFT 7,031 Reputation points

    Hi @peter liles ,
    Why you don't put the javascript file in the specific pages instead of in the global? I suggest you could write the drag function in the javascript file and then you could reference the javascript file in the specific pages.

    Best regards,
    Yijing Sun

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

  2. peter liles 471 Reputation points

    Although i have another page that utilizes same function so i placed into a global file instead of keeping on page.