开发者

How to get event of self.location change?

So what I want is to do this:

if (top != self) {
    top.location = self.location;
}

on self.location; change event. (it is possible to use jQuery if really needed but I would love not to) Is it possible and how to do such thing?

The main idea is to keep all popup windows on top. And here we try to modify window开发者_如何学Go code so that it would get onto top when user clicked on main page to open new one. So I figured we shall subscribe and listen to self.location change event. I wonder how to do it?


Are you trying to do 'frame busting'? Or are you wanting to know when top.location changes? If the latter, I presume this is to detect changes to the hash tag value of the URL, otherwise a location change loads a new page, thus your JS could never run.

If you want to check hash-tag change events (that is, content that is after the # in a URL), read up on this similar question on SO: On-Window-Location-Hash-Change.

If this is about frame busting, there are a lot of good related questions on SO such as Frame Buster Buster.

As well as a interesting blog post on Coding Horror.


Did you mean?

if (top.location != self.location) { top.location=self.location; }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜