doubutao6216 2017-06-20 14:11
浏览 116
已采纳

第一次单击后是否可以更改iFrame样式(不在同一域中)

I have a page on which I have an iframe (containing a page from another domain) and it is set to show a certain part of the page. However, I want to make it so that after the first click the iFrame moves to show a lower part of the source page. Is this possible?

With regards,

SJA

  • 写回答

1条回答 默认 最新

  • duanfen1992 2017-06-20 14:30
    关注

    Your overall solution is formed of following steps:

    1. You should detect the click on iframe

    2. then reload the second target which you need to be scrolled to in the iframe's inner page.(e.g. : [iframePageURL]/index.html#secondTarget)

    Now lets dive into detailed explanation:

    item 1 in detail: in order to detect click on an iframe you need to put a transparent overlaying layer on it : Consult the answer here which has offered the solution in detail. You just need a flag to unset it after the first click.

    Item 2 in detail: Now that you've got user's click on the iframe, change the iframe's src to the desired target, using sth like this:

    document.getElementById('calendar').src = loc;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建