AspAlliance.com LogoASPAlliance: Articles, reviews, and samples for .NET Developers
URL:
http://aspalliance.com/articleViewer.aspx?aId=452&pId=-1
Cross Domain Page Refresh - Parents Watching thier Children
page
by Justin Owens
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 10565/ 25

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>


Product Spotlight
Product Spotlight 

©Copyright 1998-2020 ASPAlliance.com  |  Page Processed at 2020-08-09 1:35:54 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search