How can I add a safe domain? I get an access error when doing this
document.all("dynamicFrame"); //my iframe
function iframeResize() {
var oBody = dynamicFrame.document.body;
var oFrame = document.all("dynamicFrame");
oFrame.style.height = oBody.scrollHeight
+oBody.offsetHeight-oBody.clientHeight;
//This is the alert call that miraculously makes this function
alert(caller +" oFrame.style.height = " +oFrame.style.height);
}
//Description:Initializes the page by creating the scroll objects
//setting browser specific information
function InitializePage(){
//d_bw.ns4||d_bw.ns5?"":iframeResize();
setTimeout("iframeResize()",2000);
//iframeResize();
}
<IFRAME APPLICATION="yes" style="width:100%;" ID="dynamicFrame"
NAME="dynamicFrame" frameborder="no" scrolling="no"
SRC="https://mydomain.com/page.jsp"> Sorry, you need inline frames to fully
see this page. </IFRAME>
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:c7*******************@news.demon.co.uk...
Nick wrote:
<snip> I don't actually want to do anything with the document if the page is
on a different domain BUT I do want to detect this situation before it
occurs, and then allow my script to terminate peacefully instead of
producing an error.
How can I do this?
I suppose I could use IE's try and catch, but that means I'll still
have problems on other browsers.
<snip>
They aren't IE's try-catch, they are specified in ECMA 262 3rd edition,
and implemented in JavaScript 1.4+, but they do represent a syntax error
in all earlier versions so are generally best avoided in cross-browser
scripting (at least for another couple of years).
You cannot determine that a document in the other frame is from a
different domain because of the security restrictions, as you have
discovered. But you don't really need to as all you actually need to
know is whether the page in the other frame is from your domain, and
thus safe to interact with. Your own pages are in a position to report
their presence to the frameset.
So, for example, you could have each of your own pages set a variable in
the frameset to true from it's onload event, and then re-set that
variable to false in its onunload event. You would then know that it was
safe to interact with the other frame whenever the variable was set to
true and unsafe whenever it was false.
Richard.