【问题标题】:IFRAME redirecting to source in mobile deviceIFRAME 重定向到移动设备中的源
【发布时间】:2014-12-28 10:58:13
【问题描述】:

在我的网站例如 (www.ABC.com) 中,有一个带有来源 (www.XYZ.com) 的 iFRAME。

iFRAME 源在单击按钮时呈现。

PC/台式机

按预期工作。单击按钮加载带有源的 iFRAME。

移动设备(所有浏览器/所有设备)

点击按钮时,www.ABC.com 被重定向到 iFRAME 的 Source,即 www.XYZ.com。

有什么问题?

【问题讨论】:

  • 按钮点击分享代码..
  • $("#button-play").on("mouseup touchend",function(){return browser.inIframe()&&browser.isMobile()?void(top.location.href=self .location.href):void

标签: iframe mobile cross-browser cross-domain url-redirection


【解决方案1】:

我想void 正在设置 iframe 的源。如果它是移动的,那么它也将它的父源设置为相同..这可能会导致问题..

$("#button-play").on("mouseup touchend",
    function(){
      return void;
    });

编辑:

所以,根据你的情况..

首先,给你的 iframe 一个 id..<iframe id='myFrame' ... >

现在,解除按钮上的所有点击事件的绑定(比如,它的id='myBtn')..

$('iframe#myFrame').contents().find('#myBtn').off( "click", "**" );

或者,解除按钮上的所有事件..

$('iframe#myFrame').contents().find('#myBtn').off();

现在,将您的功能分配给此按钮..

$('iframe#myFrame').contents().find('#myBtn').on( "click", function() {
        //your code to fire on click of myBtn
    });

让我知道它是否适合你.. :)

【讨论】:

  • DOMException: 阻止源为“www.XXX.com”的框架访问跨域框架
  • 对不起,.. 这是错误 $('matterport').contents().find('#myBtn').off();未捕获的类型错误:无法读取 null 的属性“内容”
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多