0

I'm trying to change the form's action of an externally hosted page that redirects to an URL so that it redirects to another one. I tried the following code:

$('.shopify-challenge__button').click(function(){
   $('form').get(0).setAttribute('action', 'https://url');
}); 

I think that there could be the following problems: Maybe I can't override the page from local, or I'm not identifying the form correctly (it has no id or class).

Thanks for your time!

Benjamin Carafa
  • 625
  • 1
  • 7
  • 12
  • Can you provide the HTML too? – Toxnyc Jul 14 '20 at 21:26
  • Normally you should not be able to do that - the browser prevents cross-scripting for security reasons. Imagine modifying a paypal page. There are possibilities to do that, but very restricted. – casenonsensitive Jul 14 '20 at 21:51
  • @casenonsensitive This is a page hosted by Shopify that shows up in the various stores (including mine) and it includes the anti-spam Chapta. I can override it with the CSS since it's still included in my domain, I just don't have the page files. – Benjamin Carafa Jul 15 '20 at 06:21
  • Ok, both pages being on the same subdomain is good (just the domain is not enough). Then the browser should allow you to communicate to another frame. In your case you need to select the frame of the hosted page first, before being able to select elements within. Have a look here https://stackoverflow.com/questions/8779728/getting-element-within-frame-using-jquery – casenonsensitive Jul 15 '20 at 06:54

0 Answers0