jQuery更改iFrame的SRC和ID [英] jQuery change the SRC and ID of an iFrame

查看:492
本文介绍了jQuery更改iFrame的SRC和ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的博客上,我正在使用一个脚本来显示匿名消息,将其作为普通用户名而不是匿名用户名.该脚本在我可以创建的页面上运行良好,但是在主机默认生成的页面上(例如/ask,其中包含无法编辑的消息框),我无法编辑询问框的代码,因此它不会工作.如果有人可以提供将要使用的jQuery代码

On my blog, I'm using a script that reveals anonymous messages as their normal username instead of anonymous. The script works fine on pages that I can make, but on pages that are default generated by my host (such as /ask, containing a message box which I cannot edit), I can't edit the code for the ask box so therefore it won't work. If anyone could provide a jQuery code that will

  1. 将ID为#askbox的iFrame SRC从"http://www.tumblr.com/ask_form/jamescharless.com"更改为"http://jamescharless.com/askbox"
  2. 从iFrame中删除ID,以便它根本没有ID

如果有人可以帮助我,那将非常有帮助.

If anyone could help me it would be EXTREMELY helpful.

推荐答案

这应该更改您的IFrame src

This should change your IFrame src

$("#askbox").attr("src", "http://jamescharless.com/askbox");

您可以尝试:

$("#askbox").removeAttr("id");

合并两个:

$("#askbox").attr("src", "http://jamescharless.com/askbox").removeAttr("id");

试图解决脚本问题...

Trying to solve your scripting problem...

在调试器中打开页面,您可以运行:

Opening the page in a debugger you can run:

document.getElementById('wrapper');

但不是

document.getElementById('ask_form') - it throws an error

B计划

如何注入新的IFrame?

How about injecting a fresh IFrame?

$('#ask_form').parent().html('<iframe width="100%" height="149" 
    src="http://jamescharless.com/askbox" frameBorder="0" 
    scrolling="no" style="overflow: hidden; background-color: transparent;">
    </iframe>');

这篇关于jQuery更改iFrame的SRC和ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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