duande1985 2014-08-25 02:12
浏览 27

通过PHP设置ID

I have the following code but it cannot be directly edited

<div class="slide-content">
<iframe src="sdsdsds" width="640" height="360" frameborder="0" title="Bing"     webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</li>
<li class="slide" data-thumb="sdsdsdsd">
<div class="slide-content">
<iframe src="sdsdsdsd" width="640" height="360" frameborder="0" title="Walmart"     webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>

</div>
</li>

I want to set IDs for the iframes so they become like so

 <iframe id="IFRAME1" src="sdsdsds" width="640" height="360" frameborder="0" title="Bing"     webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>

I'm somewhat proficient in PHP but don't know how to do this; this would have to be in the code and set through some way.

Help! :-)

  • 写回答

1条回答 默认 最新

  • dras2334 2014-08-25 02:31
    关注

    If you know the src= attributes, you can do this with JavaScript. I know that's not what you asked for, but I believe it'll work.

    You can get a collection of iframe elements with document.getElementsByTagName('iframe'). A collection behaves like an array, so you can iterate over it. Check the src= attribute (available in the .src property), figure out the ID you want to use, and use setAttribute("id", "whatever"); to set an ID on each iframe. You can hook this to onload and the iframes will have IDs when you need them.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)