如何创建iframe按钮以嵌入网站

时间:2014-01-23 12:04:33

标签: javascript ruby-on-rails iframe ruby-on-rails-4

我已经创建了一个本地站点,用于我在rails中进行的一些辅助项目。

我正在创建一个基本上打开模态弹出窗口的网站,并显示有关其当前所在网站的一些数据。所以网站的标题和元描述就是它。

我想知道创建一个上面是我网站的iframe是多么容易,但我可以放置另一个我设置的测试网站以测试一些功能?

我在rails中使用mechanize来获取数据,这很容易,但我想知道如何在网站上创建嵌入式按钮?

来源'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

# Lets start my custom gem pile here:

gem 'mechanize', '2.7.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

1 个答案:

答案 0 :(得分:0)

在创建iframe按钮单击时编写此代码

$('#button').click(function() {
if($('#myIframe').size() == 0) {
    $('<iframe id="myIframe" src="http://stackoverflow.com"></iframe>');
}

});