0

I've looked up all sorts guides and founds that it's technically possible with jQuery, so I download Header and Footer Scripts ( a plugin ) and managed to get a console.log working with jQuery.

The code I have so far is:

<script type="text/javascript">
  jQuery(document).ready(function() { 
    console.log('Hi');
  });
</script>

I want to make the border-radius of a button in the iFrame 0, and it's Id="lc_form_submit", so is it possible for me to do that?

I want to do more, but I'd probably be able to figure out the rest if I can get help with his part

Thanks!

Elad Karni
  • 145
  • 1
  • 4
  • 17

2 Answers2

1

Short answer:

It's no longer possible to manipulate an iframe who's content originates from outside your domain.**

Longer answer:

What you have is code to log Hi to the on your site's console - which also doesn't need the jQuery wrapper, you can just do <script type="text/javascript">console.log('Hi');</script> since console logging doesn't require jQuery.

Unfortunately, jQuery will not allow you to manipulate contents of an iframe that's not hosted on the same domain. It used to, but there were a ton of XSS issues opened up with malicious intent.

For instance, if you were to attempt to do this:

<iframe id="hats" src="https://17hats.com/iframe/"></iframe>

<script type="text/javascript">
  jQuery(document).ready(function($){
    $('#hats').contents().find('body').html('<div>Hello World</div>');
  });
</script>

You'll get the error Blocked a frame with origin "[your-website]" from accessing a cross-origin frame.

I'd look up some references on Cross Origin and XSS in general.

Essentially, if you're using iframed content you don't control, you can't do really anything about it.

Community
  • 1
  • 1
Xhynk
  • 13,513
  • 8
  • 32
  • 69
  • If you're *adamant* about changing the border radius on a button, you'll need to use a PHP cURL request or jQuery.load() function to get the markup, manipulate it in PHP or Javascript, and then output that - which is honestly *waaaaay* too much work for a border radius. If you do **need** (life or death) to do more than that border radius, truthfully since you're still figuring out `console.log('Hi');` this would probably be a request for a more seasoned developer on a platform like fiverr or codersclan. – Xhynk Feb 23 '18 at 23:02
  • So I tried your code and got - `Invalid or unexpected token`. Any idea what the issue is? Sorry, I don't understand what you mean by fiverr or codersclan? – Elad Karni Feb 23 '18 at 23:13
  • Did you read my whole answer? I did have a typo in my code (which is fixed), but the gist is that it's **not possible to manipulate iframed content**, even with jQuery. If you absolutely have to, you'll need to pay a developer to figure out a solution - Fiverr and CodersClan are websites where you can hire devs for projects. But depending on how 17hat's servers are set up, it may not even be possible. – Xhynk Feb 23 '18 at 23:16
  • I did read it. Sorry, seems I misunderstood you. I was under the impression that I was supposed to see what your code would spit out and if it would error. It doesn't throw an error though – Elad Karni Feb 23 '18 at 23:25
  • I've clarified the answer a bit, but the short answer is: what you want to accomplish is no longer possible - though it used to be. – Xhynk Feb 23 '18 at 23:32
  • Thanks! I wish I had better news for you, but a bunch of malicious people took the fun away from the rest of us haha – Xhynk Feb 24 '18 at 04:00
0

If your iframe content is cross-domain, you cant't access its DOM.

Else this is how you would do it in plain Javascript and jQuery.

Fpunkt
  • 976
  • 7
  • 13