Avatar of CPSRI
CPSRI
Flag for United States of America asked on

access the url of the iframe/frame/frameset from its src

Hi,
I want to prevent un-authorized forwards to my domain, i noticed that some people are redirecting their websites to my website using frame/iframe/frameset. How can I prevent that? I can program in asp.net, asp..any ideas..

Thanks in advance.
ASP.NETASPHTML

Avatar of undefined
Last Comment
CPSRI

8/22/2022 - Mon
sammySeltzer

Use frame-busting code similar to this:

if(top != self)
   {  
      window.open(location.href, '_top');  
   }

The use of  _top as the target parameter for window.open() will launch it in the same window.

There are other ways to do this but this is the easiest to me.
COBOLdinosaur

I you are just trying to prevent the pages from being framed then just add this script to the pages being framed.

<script language="Javascript">
<!--
if (top.location != self.location) {
top.location = self.location.href
}

//-->
</script>

Cd&
ASKER CERTIFIED SOLUTION
COBOLdinosaur

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
CPSRI

ASKER
THank you so much..
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck