0

I want to add a iframe to my website that has a button in it and when someone clicks on it, it does an action like maybe forward to another page or echo a message. I don't care about the code whether its java, php, html, etc as long as it works. I'm good at coding certain things but this is not one of them, help me out please.

UPDATE: the iframe is: iframe src="http://ipget.tk" /iframe

when its clicked on I want it to go to google.com the iframe will be on a test page on scazioco.com

Flim
  • 3
  • 4

1 Answers1

0

Using Jquery you can bind an event to your IFrame :

    $('#iframe_id').bind('click', function(event) { 
        window.location = http://www.google.com    
     });

Replace #iframe_id with the actual Iframe's ID

Murtaza Mandvi
  • 9,755
  • 22
  • 68
  • 103
  • can you give me a full example code that lets say when it detects a click on an iframe it forwards to google. please. – Flim Mar 19 '13 at 20:25
  • Thank you! One last question, if I wanted to change the website google.com to a php action that brings random rows from mysql can I do that? So like it gives random links from a database? – Flim Mar 19 '13 at 20:28
  • oh and what if there is 2 iframs and I wanted them both clicked before forwards to the next page? – Flim Mar 19 '13 at 20:29
  • Are you saying you want to POST to an Iframe? : http://stackoverflow.com/questions/168455/how-do-you-post-to-an-iframe – Murtaza Mandvi Mar 19 '13 at 20:30
  • I'm not sure I understand your comment about 2 iFrames being clicked at once? – Murtaza Mandvi Mar 19 '13 at 20:32
  • Nevermind everything I said, I just want to know if there was two iframes and I wanted them both clicked on and then an action to go to the next page, what would be the code? They both must be clicked on first then go to the new page. – Flim Mar 19 '13 at 20:33
  • Just use the code above twice, with 2 different iFrame Ids and both going to whatever location you want them to redirect. – Murtaza Mandvi Mar 19 '13 at 20:36
  • Can you please mark this as answered? I see you have just started using StackOverflow, just a suggestion :) – Murtaza Mandvi Mar 19 '13 at 20:42