如何检测iFrame是否被重定向到另一个URL? [英] How can I detect if an iFrame gets redirected to another url?

查看:1187
本文介绍了如何检测iFrame是否被重定向到另一个URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想列出一个带有分类广告的iframe。有时,当商品不再可用时,供应商会将页面重定向到其主页。我希望能够识别出这一点,以便假设它已售出,我可以取消该项目的索引。实现此目的的最佳方法是什么?

I want to list an iframe with a classified ad in it. Sometimes the vendors redirect the page to their homepage when the item is no longer available. I want to be able to identify this so I can de-index the item assuming it has sold. What is the best method to accomplish this?

推荐答案

您可以使用jQuery的加载函数来激活onload或reload。

You can use jQuery's load function that fires onload or reload.

http://api.jquery.com/load/

您需要存储iframe重新加载的次数。

You will need to store the number of times the iframe has reloaded.

类似的东西,

var reloaded = 0;
$("#iframe_id").load(function(){
    reloaded++;
});

这篇关于如何检测iFrame是否被重定向到另一个URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆