frame breaking detection [SOLVED]

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

frame breaking detection [SOLVED]

Post 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.
Last edited by s.dot on Sat Jan 05, 2008 9:15 pm, edited 1 time in total.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Thanks, that is exactly what I was looking for.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply