0

HTML

    <a onclick="readMore('<%:p.Link %>')" class="actionButton">READ MORE</a>

  <iframe id="iFrameBlog"></iframe>

JS

  var readMore = function (blogUrl) {
        $('#iFrameBlog').src = blogUrl;
    };

My Question : When above hyper link clicks,I need to show that url on iFrame's src and need to show that page.But iFrame always stays as empty.Any help ?

enter image description here

Sampath
  • 63,341
  • 64
  • 307
  • 441

1 Answers1

4

Try this,

 $('#iFrameBlog').attr('src', blogUrl);

instead of

 $('#iFrameBlog').src = blogUrl;
Krish R
  • 22,583
  • 7
  • 50
  • 59
  • Perfect.It's working.But can you tell me why my one doesn't work ? – Sampath Feb 18 '14 at 15:13
  • 1
    if you are using javascript , you can write as `document.getElementById('iFrameBlog').src=blogUrl;`, But in jquery you need to use `.attr()` – Krish R Feb 18 '14 at 15:15
  • @Sampath, because you're using jQuery, not Vanilla JavaScript. The documentation is easy to read. -> ***http://api.jquery.com/*** So easy, anyone can do it. Even people completely new to jQuery. – SpYk3HH Feb 18 '14 at 15:16