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 4624808
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:10:56+00:00 2026-05-22T03:10:56+00:00

I have a small widget. I want only a few websites to embed my

  • 0

I have a small widget. I want only a few websites to embed my widget through an iFrame.

_________________
| Friend         |
|   __________   |
|   | Widget  |  |
|   |_________|  |
|________________|

“Easy!”, you say. Just put this in the beginning of your widget code:

if (!/^http:\/\/([a-z0-9]+\.)?friend\.com)/.test(document.referrer)) {
   alert('hacker detected');
   return;
}

But this code will fail to protect us if a hacker does this:

_____________________
| Hacker             |
| _________________  |
| | Friend         | |
| |   __________   | |
| |   | Widget  |  | |
| |   |_________|  | |
| |________________| |
|____________________|

Through clever CSS, the hacker can chop off Friend’s layout and only show the widget. No one would suspect any kind of hacking was going on. So you say again, “Easy, lets do this:”

if (!/^http:\/\/([a-z0-9]+\.)?friend\.com)/.test(top.location.href)) {
   alert('hacker detected');
   return;
}

But this still doesn’t work. You get a permission denied error when reading top.location.href. Hacker, Friend, and Widget all have different domains so this is a cross-site scripting error.

Before you laugh and say “no hacker is going to go through all this trouble doing this”, I want to say that I’ve already found people doing this. The widget in question has sensitive data that I’m only legally allowed to show on certain websites.

  • 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-05-22T03:10:57+00:00Added an answer on May 22, 2026 at 3:10 am

    You gotta ask your friend to implement code that will keep his site from being used as an iframe.

    if(top != self){
       alert('Hacker Attack');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to have a small login widget that I embed within
I want to have a small QFormLayout that grows to fill its parent widget.
I have a small problem with a SWT.Browser widget who throws a quite puzzling
I have written a small WPF widget using C# that displays the current CPU
I have a small widget on my website that contains a list of events.
I have developed a small widget library of Chart controls and wondering if there
I have a small problem with adding widget to QMainWindow. When i do it
I have a widget which can pop up small dialogs when clicked. These dialogs
I have a listview embed in a spinner within the onCreate method. I want
have small problem, and would very much appreciate help :) I should convert byte

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.