2

I have a job board website/script that uses 3rd party content that I collect from an XML feed. When the applicant hits the apply button for a job, an iframe opens but they are redirected to another website to apply. I would like the domain in the iframe to stay the same as my domain so they would appear to be applying on my domain. I tried changing:

window.location = '<?php echo jb_escape_html($data['app_url']);?>';

To

$('iframe').attr('src','<?php echo jb_escape_html($data['app_url']);?>';

But the iframe does not load the redirected url and gives a blank page as output. please help me overcome this hurdle.

Here is the original code

// redirect the user to a custom URL

    jb_app_redirect_script($data);



} elseif (JB_ONLINE_APP_SIGN_IN!='YES') {

    // users can apply without logging in

    jb_app_redirect_script($data);

}


}

function jb_app_redirect_script(&$data) {

    ?>

    <script type="text/javascript">
        function js_redirect() {
            // //parent.window.location = 'http://www.cnn.com/';
            window.location = '<?php echo jb_escape_html($data['app_url']);?>';
          }
          window.onload = js_redirect;
    </script>

    <?php


}

$JBMarkup->body_close();

$JBMarkup->markup_close();
Humayun Shabbir
  • 2,961
  • 4
  • 20
  • 33
  • to add to this senario. there is an apply button that make a call to this code. I dont know if im am suppose to edit that form button code also to make it work correctly. Here is the code for the apply button – user3889687 Jul 30 '14 at 00:52
  • ', '', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=1,width=750,height=500,left = 50,top = 50');return false;" class="form_apply_button" value=""> – user3889687 Jul 30 '14 at 00:53
  • bleh - code formatting in comments is awful - can you please edit your question and add the code there instead? – Taryn East Jul 30 '14 at 00:54
  • I assume your jb_escape_html function is messing with the URL. Can you paste the iframe src after your function runs or echo the result of – Jonathan Crowe Jul 30 '14 at 00:57
  • Taryn im sorry about pasting the code in the comment. this is my first time using this forum. jonathan, yes that could be the issue. the iframe loads but the page is white and seems as its hung. I'm not the most experienced coder but i know how to edit code well. As far as the function runs or echo the result of , i've been unsuccessful trying to locate what file that command would be on my server. is there a generic file where that command would reside? – user3889687 Jul 30 '14 at 01:26

1 Answers1

0

If you don't have control over the 3rd party site, you will be hit with the cross-domain policy when attempting to interact with that iFrame.

If you're trying to circumvent this by artificially altering the domain, it won't work. However, if you do have control over the iFramed site, this is a good post for communicating between the two: Cross domain iframe issue.

Community
  • 1
  • 1
ckirksey3
  • 1,117
  • 9
  • 13
  • the third party site encourages that i hide their domain to make my site more personal for the user and does care whether i hide it or not. so thats not an issue. I can make a permanent iframe to open to another page but the issue with this code the url on every page is going to be different because each job has a unique id/link. – user3889687 Jul 31 '14 at 03:22