PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, November 30, 2022

[FIXED] How to open another website within the body of my website

 November 30, 2022     html, iframe, javascript, ruby-on-rails, ruby-on-rails-4     No comments   

Issue

I have a Rails 4 app. I'd like for my user to be able to click on a button and open another random website within the page they are currently on. The users could then navigate the new website and my page would maintain it's navigation bar and border around the new website.

How should I create this feature?


Solution

Well, why don't you create an iframe and create a trigger (button in this case) to navigate that iframe. With Jquery it's simple:

Javascript (jQuery)

$("#button").click(function () { 
      $("#iframe").attr("src", "http://www.google.com/");
});

HTML:

<iframe id="iframe" src="" width="100%" height="400"></iframe><button id="button">Load</button>

try something like this. But make sure you load jQuery first :)



Answered By - Kirill Chatrov
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing