Cross Domain Page Refresh - Parents Watching thier Children
page 1 of 1
Published: 06 May 2004
Unedited - Community Contributed
Abstract
Cross Domain Page Refresh - Parents Watching thier Children With several of the changes in the javascript security model setforth in Internet Explorer by Microsoft, a lot of cross domain functionality has been removed making it more difficult to do simple things. While most of the changes are for the best (removing security holes), I have to admit some have greatly impacted how I handle site scripting.
by Justin Owens
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 8330/ 15

Cross Domain Page Refresh - Parents Watching thier Children

With several of the changes in the javascript security model setforth in Internet Explorer by Microsoft, a lot of cross domain functionality has been removed making it more difficult to do simple things.  While most of the changes are for the best (removing security holes), I have to admit some have greatly impacted how I handle site scripting.

Recently, a major project has called for some of this functionality, namely cross domain refreshing which in some programming circles has regarded as impossible.  After a little bit of research, I found a simple and elagant solution to this problem. When Microsoft removed the ability to control browser windows in different domains, this mostly effected window control methods like window.location, window.src, etc.

For example:

a = domain a
b = domain b

b cannot set a.location,a.src or cause a to reload even if it spawned a as a child in a new window.  This is possible in single domains and from sub domain to sub domain, but not across primary domains.

However, the status of a can be monitored from the b domain as it is a child window of b. Therefore, if we check to see window a closes.  If it does close, b, the parent refreshes itself.

This type of refresh is particularly useful if you have an application that edits content or material on different domains from one domain (Application Service Provider).

Below you will find sample scripting of the refresh. Enjoy! If you find this code useful, let me know at:
justin at twistedbrilliance dot com

ASP Example

<html>
<head>
<script>

var vWin
function openwindow(){
vWin = window.open( 'http://www.google.com' );
}

function tWin() {
if (vWin.closed) {
document.location = document.location;
}
else {
setTimeout("tWin()", 500);
}
}

</script>
</head>

<body>
<a href="javascript: void( 0 );" onClick="openwindow(); tWin();">Click Here to Test.</a>
<%=Now%>

</body>
</html>



User Comments

Title: Great stuff   
Name: Bilf
Date: 2012-04-16 11:29:48 AM
Comment:
Just what I was looking for.
Title: Amazing   
Name: sumesh
Date: 2008-06-05 4:28:06 AM
Comment:
Amazing scripts.... searching something like this for long.....
thanks ... thank you so so much
Title: Great Articles   
Name: vishal vasani
Date: 2007-08-23 12:30:49 PM
Comment:
Good Articles i have used the code.....
Title: Good Articles   
Name: Vishal Vasani
Date: 2007-08-23 12:29:12 PM
Comment:
Hi,

It a Good Articles it very helpful....
Title: good   
Name: acil
Date: 2007-06-27 5:30:02 AM
Comment:
it's so good
Title: Hope this works   
Name: Jerome Bohg
Date: 2006-03-20 5:57:38 AM
Comment:
Hi there. If this script really does what is says then it'll make my day. Have been searching a long time for something likethis. I'll test the script this evening.

many thanks in advance

Jerome

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-23 1:57:14 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search