-2

I have the following code:

$( 'body' ).replaceWith( '<iframe src="http://google.com" frameborder="0" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:100%;width:100%;position:absolute;top:0px;left:0px;right:0px;bottom:0px" height="100%" width="100%"></iframe>' );

It replaces the whole content of the page with the iframe. However I would like that the above code to vary its iframe source if the form sent a specific value.

For example if:

<input name="any_other_value" value="any_value" type="radio">

Is selected, then the jQuery code posted above shows a different iframe.

Do you think this can be achieved with jQuery?

700 Software
  • 85,281
  • 83
  • 234
  • 341

1 Answers1

0

This code looks to see whether the radio button is checked. If so, the src of the iframe is adjusted.

var desiredSrc = 'http://google.com'
if($('input[name="any_other_value"][value="any_value"]').is(':checked'))
    desiredSrc = 'http://example.com'
$( 'body' ).html( '<iframe src="' + desiredSrc + '" frameborder="0" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:100%;width:100%;position:absolute;top:0px;left:0px;right:0px;bottom:0px" height="100%" width="100%"></iframe>' );
700 Software
  • 85,281
  • 83
  • 234
  • 341