Osensnolf
Osensnolf

Reputation: 17

Redirect into Parent Window

Google sends many people to my website using the translator. It is not needed. Therefore, when someone arrives, it looks like this:

http://translate.google.com/translate?hl=en&sl=de&u=http://stackoverflow.com

The site functions OK but not 100% like it should.

I would prefer to have an index.php (or HTML) file that is a redirect to the main URL. It should target and replace the entire window (removing any reference to Google Translate).

I tried different variations of the below but it did not work.

<META http-equiv="refresh" content="0;URL=http://www.domain.com" target="_new">

_parent and _top were tried.

Can you please help with this?

Upvotes: 0

Views: 831

Answers (3)

Jordan Cortes
Jordan Cortes

Reputation: 281

You can look up in the URL for an specific word (like google) to see if the path was altered and then do the redirect.

var site_url = window.location.href;

if (site_url.indexOf("google") > 1)
{
  window.location = "http://example.com";
}

Upvotes: 1

Lakshman Kambam
Lakshman Kambam

Reputation: 1618

<script type="text/javascript">
if(window.parent&&window.parent!==window){
    window.parent.location='//example.com';
}
</script>

Paste it in your index page and run it!!!

Upvotes: 0

AlexanderB
AlexanderB

Reputation: 989

This should redirect to example.com if it accessed via iframe, which is how translator do it.

<script type="application/javascript">
    if (window.parent && window.parent !== window) {
        window.parent.location = '//example.com';
    }
</script>

Upvotes: 2

Related Questions