tmonteit
asked on
Can't trigger javascript from seperate page.
Beginner question. I have 2 pages. When I click on page 2 I want it to load page 1 AND execute javascript on the first page.
The solution I tried is to use a hash (see code below: Page 1 is 'puppies'. Page 2 is 'index.html')
There is a live example running that demonstrates this problem:
Link to the Page http://107.22.173.10
Link to the trigger I can't get working: http://107.22.173.10/index .html#runF unction1
I know very basic javascript and I need some expert help debugging this. Any ideas what is happening here? How can I achieve the functionality I want?
The solution I tried is to use a hash (see code below: Page 1 is 'puppies'. Page 2 is 'index.html')
There is a live example running that demonstrates this problem:
Go to http://107.22.173.10 then click Item 1. This is the result "I like puppies" is I want to see when I click the hashed index.html
Then click "puppies" and click Item 1 from that page. It should produce the same result but it doesn't
Link to the Page http://107.22.173.10
Link to the trigger I can't get working: http://107.22.173.10/index
I know very basic javascript and I need some expert help debugging this. Any ideas what is happening here? How can I achieve the functionality I want?
Page 1 Code:
<a href="index.html#runFunction1">Item 1: triggers index.html#runFunction1</a>
Page 2 Code:
function showItem1() {
$("txtCtr").update("<h2>Item 1</h2> <p>I like puppies.</p>");
}
if (window.location.hash == '#runFunction1') {
showItem1();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The trigger worked perfect! Thanks a bunch. Unfortunately the code failed for another reason. I will ask a separate question.
Cd&