473,382 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

is it possible to communicate with another domain javascript function using ajax

hello,

Is it possible to communicate with another domain javascript function using ajax.
Suppose i have a iframe and domain is different and in the iframe i have some links. If user clicks on that link i want to call javascript function written in main page (not in iframe). is this possible using ajax to call the java script function of another domain.
if possible please tell me the example.
if not please tell me the another way.

please help me out...............

Thanks in advance.
Jan 7 '09 #1
8 3582
rnd me
427 Expert 256MB
not possible.

you will have to use a "proxy" for your server that can fetch page from other domains and re-broadcast them from your server. only if if the pages are on the same server can a click action be passed like that.
Jan 7 '09 #2
the two frames can communicate with each other by using fragment identifiers (the hash part of an URL, like http:// some.domain.com/path/to/page.html#fragmentIdentifier).

some thing like that is possible using ajax please let me know.............
Jan 7 '09 #3
xNephilimx
213 Expert 100+
@pankaj17
that's true. You can also use a hidden iframe, and access it with js, or you can use curl (in php or any server side language) to get the content from another domain, and then ajax to query the script that makes the curl petition.
Jan 7 '09 #4
rnd me
427 Expert 256MB
@pankaj17
while that can be used to pass data, it will not allow a page to invoke a function on the parent page, the original question.
Jan 7 '09 #5
xNephilimx
213 Expert 100+
@rnd me
I'm not completely sure, but can't you call a function in the parent window with window.parent.func_name ?
Correct me if 'm wrong, because I'm not sure.
Jan 8 '09 #6
rnd me
427 Expert 256MB
@xNephilimx
you can in the same domain.
the object property is there in other domains, but accessing it will raise an exception unless security policies have been altered in some fashion.

this is the case in all browsers by design, save some old IE versions that accidentally let some things slip.
Jan 8 '09 #7
xNephilimx
213 Expert 100+
@rnd me
Thanks, rnd_me! I didn´t know that, never tried it.

Maybe, pankaj17, you can set event listeners in the iframe's content, getting the iframe document element and checking for it's ready state using jquery, then adding the listeners. Don't know about security exceptions that may raise though, I should try.
Jan 9 '09 #8
rnd me
427 Expert 256MB
@xNephilimx
you aren't allowed to reach the document.

i have seen this link, and been meaning to try it.

let me know if anyone has any luck.
Jan 9 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Kenny Lai | last post by:
hey, Is there a way to communicate between iframes on different subdomains? e.g. from one.dot.com to two.dot.com? there is a security access restriction passing javascript commands between...
1
by: totalstranger | last post by:
Has anyone found a reasonable, simple way to determine the height of variable length embedded data in a cross-domain IFRAME? I'm not interested in reading or viewing the data in the IFRAME, I...
6
by: Simon | last post by:
Hi All, An experiment i'm doing requires requires a synchronous cross-domain request, without using a proxy. I wondered if anyone had any ideas to help me achieve this. Below is what I have...
0
by: Tarik Monem | last post by:
I have been working on an all AJAX/DOM web site which is set to go live today and I thought I'd share my discoveries with all of you whom have helped me when I have encountered different issues along...
6
by: Bart Van der Donck | last post by:
Hello, I'm presenting my new library 'AJAX Cross Domain' - a javascript extension that allows to perform cross-domain AJAX requests. http://www.ajax-cross-domain.com/ Any comments or...
4
by: Oriane | last post by:
Hi Steven, "Steven Cheng " <stcheng@online.microsoft.coma écrit dans le message de news:ZJOyi9J4IHA.4928@TK2MSFTNGHUB02.phx.gbl... Thanks for the link. I've tried that but there is one withdrawal...
6
by: totalstranger | last post by:
Using an AJAX Javascript function that works fine if it's in the primary domain www.arnb.org, but suffers from a security error when attempted from a subdomain, thepatsyreport.arnb.org In the...
2
by: Mike Harrison | last post by:
Hi, is it possible to do something like this using JavaScript? My page should prompt the user for a 3rd party URL. It will then validate this URL, request the page, analyse it and update the main...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.