Page 1 of 1

frame breaking detection [SOLVED]

Posted: Sat Jan 05, 2008 12:55 pm
by s.dot
I have this javascript:

Code: Select all

<!--
function breaksFrames(ok)
{
	if (ok)
	{
		if (ok == 1)
		{
			if(confirm("The page is breaking frames.  Press OK to close the window, or Cancel to report."))
			{
				return true;
			} else {
				window.open("page-to-report");
				return false;
			}
			return true;
		}
	}
}
// -->
And I'm calling it like this on my frames page

Code: Select all

<FRAMESET rows="100,*" onbeforeunload="breaksFrames(1);">
It works good for closing the window and pages that have javascript that breaks frames. The problem is, one of the two frames has content that links to the frame set page via a link. It's essentially a refresh, reloading the two frames. I don't want this link to trigger the above onbeforeunload().

I've tried making the link with this attribute:

Code: Select all

onclick="window.frames[0].breaksFrames(0);"
But it doesn't seem to work.

Posted: Sat Jan 05, 2008 6:15 pm
by JellyFish
If you are trying to access a function/object outside of a iframe or frame, I do believe, you can access them throught the window.top property.

Posted: Sat Jan 05, 2008 9:15 pm
by s.dot
Thanks, that is exactly what I was looking for.