【问题标题】:JQuery | How to get attributes of iframe from other html? [duplicate]jQuery |如何从其他 html 中获取 iframe 的属性? [复制]
【发布时间】:2014-12-06 15:17:30
【问题描述】:

我想从其他 html 中获取 iframe 的属性 'src'。

我可以在同一个html中获取iframe的属性,但不能从其他html中获取,

看看我的代码:

/////////iframe attribute from the same html//////////

   var Mframe_src = $("#Mframe").attr('src');

   alert(Mframe_src);

//////////iframe attribute from other html////////////

var frame_Ads = $("#Mframe").contents();

var Ads_src = frame_Ads.find("#ads");

alert(Ads_src.attr('src')); /// the alert present me undefined

【问题讨论】:

  • “其他 html”是什么意思?
  • "other html"其他域???
  • iFrame 是否与主 HTML 来自同一域?

标签: javascript jquery html get


【解决方案1】:

这是不可能的,您可以尝试通过 ajax 获取 iframe 内容,然后对其进行处理。

$.get("my iframe page").success(data){
//do something
});

【讨论】:

    猜你喜欢
    • 2013-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-26
    • 1970-01-01
    • 2015-10-25
    • 1970-01-01
    • 2015-09-16
    相关资源
    最近更新 更多