更改iframe的src,然后重新加载iframe [英] change src of iframe and then reload the iframe

查看:2133
本文介绍了更改iframe的src,然后重新加载iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法用javascript更改iframe的src

I managed to change an iframe's src with javascript

var path='images/tattoo/fullsize/';
var h=$('#borderlessFrame').height();
var bigFrame=$('#borderlessFrame');
function loadGallery(num)
{
    bigFrame=$('#borderlessFrame');
    var galPath=path + num;             // path to the image
    h=$('#borderlessFrame').height();
    var source=bigFrame.attr('src');
    source='i load some address here';
}

但是现在我看到了iframe的旧内容,有没有办法重新加载iframe(只有iframe而不是整个页面)
我想要实现的是一个简单的画廊,底部的拇指图片和顶部的大图片(iframe)。点击任意一个拇指,我更改iframe的内容而不重新加载实际页面。

But for now i see the old content of the iframe , is there a way to reload the iframe ( only iframe not the whole page) The thing i am trying to achieve is a simple gallery , thumb pictures on the bottom and a large picture on the top ( iframe ). On click on any of the thumbs , i change the content of the iframe without reloading the actual page.

请记住,我是html / javascript / jquery的新手。
所以基本上我需要一种方法(函数?)来重新加载iframe。

Keep in mind that i am new to html/javascript/jquery. So basically i need a way(function?) to reload the iframe.

推荐答案

要设置属性,你需要调用 .attr(attributeName,value)

To set attribute, you need to call .attr( attributeName, value )

试试这个:

var source='i load some address here';
bigFrame.attr('src', source);



参考:



jQuery .attr()

这篇关于更改iframe的src,然后重新加载iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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