Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8301697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:06:36+00:00 2026-06-08T17:06:36+00:00

Edited question In summary: I got 2 sites siteA.com siteB.com Iframe belong to siteB.com

  • 0

Edited question

In summary:

I got 2 sites
siteA.com
siteB.com

Iframe belong to siteB.com
But i want allow siteA.com to iframe siteB.com page too. However anything that not siteA or siteB.com will be redirect to siteA.com

using javascript, how do i check, consider to ignore with www or without www(wildcard) and also that my site could be siteA.com/pretty-url

How do i do the check and add in the security with javascript , which any random site not authorize will result in window.top.location.href being redirect to siteA.com

Thanks for all help, new here 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:06:38+00:00Added an answer on June 8, 2026 at 5:06 pm

    Something like this?:

    if (window.top != window && !window.top.location.href.split('?')[0].split('#')[0].match('mysitedomain.com'))
    {
        window.top.location.href = window.location.href;
    }
    

    The first check is making sure you only run this code if your site is in a frame.
    The second check is looking to see if url of the top frame (browser window) contains your domain. We need to ignore the querystring/anchor incase it looks something like this: http://notmine.com/path/file.html?subframe=mysitedomain.com

    This would still match:

    http: //not*mysitedomain.com*/path

    In the .match(…), you could include http:// or https://.

    Update to answer your edits:

    var topUrl = window.top.location.href.split('?')[0].split('#')[0];
    
    if (window.top != window && !topUrl.match('siteA.com') && !topUrl.match('siteB.com'))
    {
        window.top.location.href = "siteA.com";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have edited this question but at the bottom of the program I have
I edited my question when I set the bounty. I want to Invoke/DllImport WSAAsyncSelect()
Question Edited : HashSet and HashMap are fail-fast(but that is not gauranteed) as mentioned
I am nearly ashamed to ask this, but... EDIT: I edited the question to
Edited Question: This should be clear. using System; namespace UpdateDateTimeFields { class Program {
I edited the question so it would make more sense. I have a function
I edited this question after i found a solution... i need to understand why
The question and description has been edited to make the user understand well what
Warning: This question has been heavily edited. I tried my best to guess the
NB: This question has been extensively edited to make it more relevant, for completeness

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.