How do I make this iframe clickable?

Discussion in 'Programming' started by saadhu, Nov 5, 2011.

  1. #1
    I have a javascript based slider banner, part of which looks like the following example:
    htmlstring="<iframe src=\"http://example.com/banner.jpg\" name=\"adpiframe\" id=\"adpiframe\" width=100% height=100% align=\"center\" Frameborder=\"0\" Scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\"></iframe>"
    new adp("template01",htmlstring,"blah blah");
    adpTimer('template01','adpSlidein','show','','',3,'');
    It shows a banner allright as expected but how can I insert some code to make banner.jpg clickable so that it opens in a new window as a new page?
    Any ideas?
     
    saadhu, Nov 5, 2011 IP
  2. Rising_Star

    Rising_Star Active Member

    Messages:
    39
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #2
    <a href=\"example.com/banner.jpg\" target="_blank"><iframe src=\"http://example.com/banner.jpg\" name=\"adpiframe\" id=\"adpiframe\" width=100% height=100% align=\"center\" Frameborder=\"0\" Scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\"></iframe></a>


    I guess that will do the job
     
    Rising_Star, Nov 5, 2011 IP
  3. saadhu

    saadhu Well-Known Member

    Messages:
    209
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    Thanks for the reply Rising_Star but it did not work. I am going to post it in services section.
     
    saadhu, Nov 6, 2011 IP
  4. dakshhmehta

    dakshhmehta Active Member

    Messages:
    220
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    85
    #4
    hello,

    You;re absolutely correct that <a> tag will not wok. This should use an event called "onClick"

    so, if you want to redirect the user on back page while clicking on that iframe, then the code should looks like:

    <iframe src=\"http://example.com/banner.jpg\" name=\"adpiframe\" id=\"adpiframe\" width=100% height=100% align=\"center\" Frameborder=\"0\" Scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" onClick=\"javascript:window.history(-1);\"></iframe>
     
    dakshhmehta, Nov 13, 2011 IP