Calling a content page's javascript from a master pages javascript

212 views Asked by At

I am working on a web app that can display data in two drastically different formats. To do this, I am using a master page with two different content pages for the differing views. I am using .svc files to do AJAX style server requests. I would like to be able to do a service call from the master pages javascript, then run the appropriate onSuccess javascript method (which would ideally lie in another .js file) to display the data based on which content page I am in. I am guessing this would be done with some kind of function delegate, but I am new to web development and not sure how to do this. Any help would be greatly appreciated.

2

There are 2 answers

0
unbootabru On BEST ANSWER

This was a stupid question... Just attach different js files to the content pages. Give the functions the same name and it works fine.

0
Plato On

If you can do everything on one page, your HTML will probably look something like this:

<!DOCTYPE html>
<html>
  <head>
    <script src="masterScript.js"></script>
    <script src="module/childScript.js"></script>
    <script>
      console.log(globalVariableFromMasterScript)
      doSomethingFromChildScript(globalVariableFromMasterScript)
    </script>
  </head>
  <body>
    <p>This is the html page</p>
  </body>
</html>