Tom Brock
Tom Brock

Reputation: 950

How to detect page opacity?

Let's imagine someone is loading my website in an iFrame, and they've set the iFrame opacity to 0, what JavaScript can I use to detect my page currently has an opacity of 0?

Upvotes: 1

Views: 103

Answers (2)

1990rk4
1990rk4

Reputation: 768

You can try this:

if($('element').css('opacity') == 0) {
    doSomething();
}

To detect the opacity

Upvotes: 0

Quentin
Quentin

Reputation: 943569

None.

The opacity belongs to the frame, not to your site. The same origin policy prevents you from accessing the parent DOM to get details of the frame.

If you are concerned about clickjacking attacks, consider x-frame-options as a defence.

Upvotes: 3

Related Questions