/    Sign up×
Community /Pin to ProfileBookmark

Calling functions from other pages

How do I write script on one page so that it calls a function that exists on an entirely different page? For example, I am currently building a webring, so I need to figure out how I can place buttons on a webring member’s webpage so that it will call javascript functions from the page on which the webring itself exits on.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@steelersfan88Mar 15.2004 — you can't ... the best oiption would be to include the function in a javascript (.js) file and include:

<script type="text/javascript" src="myScript.js"></script>

And then you can call the function from multiple pages.
Copy linkTweet thisAlerts:
@AngelicKnightauthorMar 16.2004 — Thanks, that worked!
Copy linkTweet thisAlerts:
@Stephen_PhilbinMar 16.2004 — I'm rather new to this javascript business. That's the first I've heard of a .js file.

Can ya pop a link up for me so I can go and learn about it please? Sounds like just the thing I need for a nightmare in code form I'm having at the mo'.
Copy linkTweet thisAlerts:
@TheBearMayMar 16.2004 — A .js file is simply a file with a collection of Javascript functions or variables, but without the <script></script> tags. You include the file by using the <script src="...> in your document.
Copy linkTweet thisAlerts:
@JayDieMar 16.2004 — now I got another problem. I've got a main.asp page. It includes this .js file. Then, in a function of main.asp, there is a showModalDialog. So, there is a new window. In this window, I want to use the functions of the .js, so I include in the new window (showModalDialog loads a .html). But...

When you use variables in that .js file, you can modify them for example by executing a function which changes the variable.

Now, I want to access this changed variable in my modaldialog. Because of I include there the .js, IT IS A NEW .JS with the standard variables, who are NOT changed!

By showModalDialog, I can't use 'window.opener'. I know, I must use dialogArguments. But, isn't there another way?

JayDie
×

Success!

Help @AngelicKnight spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...