Dynamically set src in iframe - not working
这是我相关的HTML:
1 2 3 4 5 6 7 8 9 | Watch RedditTV Topics <iframe id="reddit-tv-iframe" style="height:100%;width:100%;" style="border:none;"></iframe> |
这是我的JQuery:
1 2 3 4 5 6 7 8 9 10 11 12 13 | $('#activity-link-reddittv').click(function(){ var el = $(this); $('#activity-menu').hide(); $('#reddit-tv-div').show(); $('#reddit-tv-frame').attr('src', el.data('url')); console.log('el = ' + el); console.log('el.url = ' + el.data('url')); console.log('src = ' + $('#reddit-tv-frame').attr('src')); }); |
这是我的日志:
1 2 3 | el = [object Object] el.url = https://app.herokuapp.com/reddit-tv/reddittv.html src = undefined |
iframe不会显示,并且基于日志
这个问题已经在SO上得到了无数的回答-一个例子。 我的代码似乎不遵循这些答案。
1 | $('#reddit-tv-iframe').attr('src', el.data('url')); |