-1

I have an HTML page in that, I included a test.js file. On click of a button, I am opening a pop up. And that will be the second HTML page.

 <script type="text/javascript" scr ="test.js">

Now, I want to use test.js for all the logic's and I don't want to include again this test.js in the pop.html. Please suggest me how can we do this.

Kunj
  • 1,980
  • 2
  • 22
  • 34
Pooja Dubey
  • 683
  • 2
  • 14
  • 34
  • why ??see the issue is again i don't have to include the js file in the pop html so can i use this js file – Pooja Dubey Feb 25 '14 at 08:07
  • Refer to the following link on StackOverflow containing solutions: [Solutions](http://stackoverflow.com/questions/950087/how-to-include-a-javascript-file-in-another-javascript-file) – Mr_Green Feb 25 '14 at 08:10
  • if the pop up is not a new window then , no need to include the js file again ,you will call the function in the js file – Karthick Kumar Feb 25 '14 at 08:13
  • @Neil I didn't insult your mother tongue language.. read my comment again. I am saying most of the users here don't know Hindi language. should they use google translate or what? btw, "area51" is a place where you can propose new sites. (I think this is the word which made you confused). – Mr_Green Feb 25 '14 at 09:17
  • If pop.html is loaded in a new document context (new page), you will have to include test.js again to have it available there. Where is the actual problem with that? – fast Feb 25 '14 at 10:57

2 Answers2

1

What you want is kind of inheritance in the templates. As far as I know this is possible in Django.

If you want to implement this using jQuery, instead of opening a second.html load it in an div.

For e.g.

$( "#result" ).load( "ajax/test.html", function() { alert( "Load was performed." ); });

If you do this test.js wont have to be included again and again.

Akash Deshpande
  • 2,583
  • 10
  • 41
  • 82
1

you can load all resources needed by pages on the first page, and extract body content of the html result returned by ajax calls.

$.get('/handler.html', function(result) {
    $('#pageContainer').html($(result).find('body').html());
});
ucdream
  • 691
  • 1
  • 7
  • 18