Avatar of MDauphinais1
MDauphinais1

asked on 

JQuery Reference Function on Another Page

Using JQuery, I have a main page (main.html) that includes a second page (test.html) with this in the header:

$("#testdiv").load("test.html");

Which works fine. But there is a link in test.html, that when run, I want it to run a function located on main.html to update some content there.

Can I do this?
JavaScriptAJAX

Avatar of undefined
Last Comment
MDauphinais1
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

You could try having it use top.functionName() or parent.functionName() but most likely that won't work.  The only reason I can't be sure is there may be some exception because of jQuery.  If testdiv were a frame or iframe then things would be different but it seems that jQuery is running the test.html page before it puts the result in the element testdiv.  Because of that the script in testdiv doesn't access main.htm and vice a versa.
Let me know if you have a question about this.
bol
ASKER CERTIFIED SOLUTION
Avatar of MDauphinais1
MDauphinais1

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo