We have successfully implemented a solution that works in IE and Firefox browsers, as demonstrated below. However, we are encountering an issue with Chrome and Safari where the content constantly loops within the iframe source. This is where we require assistance to resolve the problem specific to Chrome/Safari.
The objective was to provide our users with direct access to a page on our site that is iframed. Upon accessing the page, it should display the appropriate iframe template. While this approach functions effectively on IE/Firefox, it does not work on Chrome and Safari.
These two pages contain identical content, but utilize different iframed templates.
For instance, by clicking this link, the user will be directed to the Awards Recognition content wrapped in the AMU template with #AMU added to the URL
Similarly, the exact same content will be displayed with the APU template using #APU appended to the URL
Below is the javascript code for the parent iframe:
<script type="text/javascript">
function gup( name ) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
var ifSrc = gup("forward");
$(function(){
if(ifSrc)
$("#iframe").attr('src', ifSrc);
});
</script>
Additionally, provided below is the code intended for the source content and the corresponding page:
<script type="text/javascript">
function fnGetDomain(url) {
if(url)
return url.match(/:\/\/(.[^/]+)/)[1];
else
return "";
}
var curDomain = fnGetDomain(document.referrer);
var curHash = document.location.hash.toLowerCase();
try { frameEl = window.frameElement; }
catch(e) { frameEl = 1; }
if(!frameEl) {
//if (frameElement == null) {
if(!curDomain) curDomain = "www.apu.apus.edu";
if(curHash == "#apu") curDomain = "www.apu.apus.edu";
else if(curHash == "#amu") curDomain = "www.amu.apus.edu";
//change location or close
window.location = "http://" + curDomain + "/community/alumni/index.htm?forward=" + document.location.href;
// or window.close();
}
</script>