Click to See Complete Forum and Search --> : checking if document in iframe is on different server


sabretooth80
04-16-2003, 07:32 AM
Hi,

I know that I will get a 'Access Denied' if the document inside an iframe is on a different domain. However, is there a way to check if the document is in a different domain?

Basically, I want to do something to the document in the iframe if the document is in my domain, but sometimes there will be documents from other domains in the iframe, in which case I would like to take an alternative action.

Thanks,
Sabretooth

sabretooth80
04-16-2003, 08:32 AM
Thanks, that went a long way toward solving my problem but now I've hit another obstacle. My page has a 'expand' button that allows the content in the iframe to be opened in a new window. Usually, the content in the iframe is from my domain. But if the content contains external links, then the external page gets opened inside the iframe.
If the user clicks one of these external links, I store this external link in a hidden field on my page so I know where the user has gone. So if they click 'Expand' after clicking an external link, I can open the external page by opening the url i stored in the hidden field by checking whether the page is on my server or not using the code supplied above.
However, if the user has clicked a link on the external page and is now on a second external page, is there any way for me to work out the url of this second external page?
I guess one solution would be to open the external link in a new window in the first place but there are other functions on my page that the user may want to perform while looking at the external page so it i feel that it is more user friendly if the external page was inside the iframe.

DrDaMour
04-16-2003, 09:18 AM
that would be a lot easier to understand if one could see it

khalidali63
04-16-2003, 10:17 AM
Here is a simple script that displays how to use exception handling features of javascript properly in your scripts.

http://68.145.35.86/skills/javascripts/ExceptionHandlingJavaScript.html

Cheers

Khalid

Jona
04-16-2003, 01:08 PM
Hey, I like it! :)

khalidali63
04-16-2003, 01:11 PM
:D
Thanks jona,
I hope it helps allots of members out here..

Cheers

Khalid

Jona
04-16-2003, 01:25 PM
Helped me... I didn't have a question, but the answer was better than expected.. :)

I've never really used throw/catch (or switch, have a script for that?), and that I know of, I haven't needed it. But I may in the future; and I always enjoy learning something new (or something I just skipped because I didn't need it at the time or didn't know about it).

khalidali63
04-17-2003, 12:26 AM
I stand corrected,I guess given the history of .....,I just took it too serious..

Cheers

Khalid