AhmNee
05-24-2006, 07:44 PM
**Edited for a typo and to clarify my problem.
I'm working on a website with multiple .js files. I'm trying to make a script that calls from one external script to another. I'm looking to make a small script that will allow a one stop shop for changing where an href points on multiple pages. The code is like this.
Webpage
<head>
<script src="/siteroot/script01.js" type="text/javascript"></script>
<script src="script02.js" type="text/javascript"></script>
<head>
<body>
<a href="#" onclick="linkSite('page_one')">Click here for Page One</a>
<a href="#" onclick="linkSite('page_two')">Click here for Page Two</a>
</body>
Script one is the function to change the page. Standard for all sites.
Script01
function linkSite (ind_var)
{
callLink(ind_var)
window.location=pass_var
}
Script two sets up where the hrefs point. This will be different per site.
function callLink (p_value)
{
//Do not modify above this line
//Place the URL for the site link in the quotes for the proper page.
page_one="/siteroot/page01/webpage.html"
page_two="/siteroot/page02/webpage.html"
//Do not modify below this line
if (p_value=="page_one")
{
pass_var=page_one
}
else if (p_value=="page_two")
{
pass_var=page_two
}
else //If the link text does not match return error.
{
alert ("Invalid Site Link")
pass_var="#"
}
return (pass_var)
}
I apparently cannot make calls to the callLink in script02.js from linkSite in script01.js, nor can I call to callLink if I embed it inline on the page in the header. In both cases I get an 'object expected' error. I belive it's because it's not finding the 'callLink' function. If I put both functions in script01, it functions properly. Here are my questions:
Is there a way around this limitation? Even if I'm doing this poorly in this case, I'd like to know if there is a way to do this reguardless for future referance.
Am I makeing an uneccesary script here? Or a poorly written one? Let me know if there's a better way to do this. Remember that the variables will change for each site within the hierarchy.
Thank you greatly for your assistance in advance.
AhmNee
I'm working on a website with multiple .js files. I'm trying to make a script that calls from one external script to another. I'm looking to make a small script that will allow a one stop shop for changing where an href points on multiple pages. The code is like this.
Webpage
<head>
<script src="/siteroot/script01.js" type="text/javascript"></script>
<script src="script02.js" type="text/javascript"></script>
<head>
<body>
<a href="#" onclick="linkSite('page_one')">Click here for Page One</a>
<a href="#" onclick="linkSite('page_two')">Click here for Page Two</a>
</body>
Script one is the function to change the page. Standard for all sites.
Script01
function linkSite (ind_var)
{
callLink(ind_var)
window.location=pass_var
}
Script two sets up where the hrefs point. This will be different per site.
function callLink (p_value)
{
//Do not modify above this line
//Place the URL for the site link in the quotes for the proper page.
page_one="/siteroot/page01/webpage.html"
page_two="/siteroot/page02/webpage.html"
//Do not modify below this line
if (p_value=="page_one")
{
pass_var=page_one
}
else if (p_value=="page_two")
{
pass_var=page_two
}
else //If the link text does not match return error.
{
alert ("Invalid Site Link")
pass_var="#"
}
return (pass_var)
}
I apparently cannot make calls to the callLink in script02.js from linkSite in script01.js, nor can I call to callLink if I embed it inline on the page in the header. In both cases I get an 'object expected' error. I belive it's because it's not finding the 'callLink' function. If I put both functions in script01, it functions properly. Here are my questions:
Is there a way around this limitation? Even if I'm doing this poorly in this case, I'd like to know if there is a way to do this reguardless for future referance.
Am I makeing an uneccesary script here? Or a poorly written one? Let me know if there's a better way to do this. Remember that the variables will change for each site within the hierarchy.
Thank you greatly for your assistance in advance.
AhmNee