Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call function?

Status
Not open for further replies.

Cap2010

Programmer
Mar 29, 2000
196
CA
hi,

Do not want to write / copy in every page.

Will store in one page and call in another page
where ever required.

[bold] Want to call a function in one web page
in another web page. [/bold]

Cap2010

 
Are you talking about a Javascript function? If so, you can put the text of the function in a seperate file like this:
[tt]
<script type=&quot;text/javascript&quot; src=&quot;/url/of/file&quot;></script>
[/tt]

If you're talking more generally about taking a file and inserting its contents into multiple web pages, check out SSIs (Server Side Includes). There are a couple of FAQs on this forum which tell you about them.

-- Chris Hunt
 
and the file name must be file.js.
it must not include <script> tags. only the functions...

Known is handfull, Unknown is worldfull
 
Chris Hunt,

Thanks, it is html file with java script.

cap2010
 
Chris Hunt,

One more question is I'm calling a function in a procedure will the same method work.

cap2010
 
It should do. As the browser encounters the <script src=...> tag it loads the javascript from the specified file. It then behaves exactly as if the script had been written inline. So anything that works with an inline script should work with the script in a file.

That said, try to make each file as self-contained as possible. It makes it easier to re-use them in future projects.

-- Chris Hunt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top