1

I have the following code which can successfully change the iframe src with a button. How can I replace the button with a textlink?

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<input type="button" id="changeframe" value="Change">

<iframe id="declinedframe" class="embed-responsive-item" src="http://forgezilla.com" height="585" width="100%" ></iframe>

// Go Last since changeframe hasn't exist yet.
<script>
  $('#changeframe').click(function () {
      $('#declinedframe').attr('src', 'http://stackoverflow.com');
  });
</script>
2
  • What do you mean by textlink? <SPAN> Commented May 1, 2017 at 8:12
  • @Arya please check this may this will help stackoverflow.com/q/20498831/5635098 Commented May 1, 2017 at 8:38

2 Answers 2

1

You don't need jQuery or JavaScript to accomplish what you want to do, you only need HTML.

  • On <a>nchor add href="http://whatever.com/path/to/new/site.html" and target="nameOfIframe"

  • On <iframe> add name="nameOfIframe"

Snippet

<a href="http://stackoverflow.com" target="declinedframe">Change</a>

<iframe name="declinedframe" src="http://forgezilla.com" height="585" width="100%"></iframe>

Sign up to request clarification or add additional context in comments.

Comments

0

just replce

<input type="button" id="changeframe" value="Change">

with

<a href="#" id="changeframe">Change</a>

This should work

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.