1

I would like to summarize my problem: I need to obscure the source of the iframe from the source code. To do this I have to use javascript code and obfuscator. By inserting the following obfuscated code it does not show me anything but the outline of the iframe.

<script type="text/javascript" language="javascript">
$(document).ready(function(e) {
    $('iframe').attr('src','https://google.com')
;}
</script>
<p><iframe id="iframe" width="1200" height="600"> </iframe></p>

Is my code wrong or is it that Joomla that fails to load the source via javascript?

1 Answer 1

3

Firstly, your Javascript contains an error so it won't run at all. Specifically you're missing a ) near the end.

Secondly, Google send a X-Frame-Options: SAMEORIGIN header, basically meaning you cannot run Google pages in an iframe unless your page is hosted on the same domain as Google itself, which is isn't.

Thirdly, I think you're misunderstood by the word obfuscate. It basically means unreadable code. Just because you're loading the iframe source via Javascript, does not mean people won't be able to see the code. This is an example of proper obfuscation: https://obfuscator.io/

and this is a working example if what you were trying to achieve in your question:

https://jsfiddle.net/Le3tcu0b/

12
  • Thank you so much for answering me! as far as the google link is concerned, I know it but it's just an example. I tried to put the code on a joomla article without having obfuscated and does not show me anything the same. Commented Jan 31, 2019 at 15:24
  • Are you getting any errors on the browser console? Are you sure the script tag isn't blacklisted by the editor?
    – Lodder
    Commented Jan 31, 2019 at 16:13
  • It gives me this error: test-generico:119 Uncaught TypeError: $ is not a function at test-generico:119 test-generico:22 Uncaught ReferenceError: JCaption is not defined at test-generico:22 at dispatch (d762053454413417c0903edb0ae51d0c_0.js:1) at v.handle (d762053454413417c0903edb0ae51d0c_0.js:1) On joomla I am using JCE editor that I have updated and I have applied the consent to execute javascript from the editor settings. Commented Jan 31, 2019 at 16:29
  • I'm sorry for interfering a bit, I just placed the missing closing bracket in the code and formatted the code for better readability...
    – Zollie
    Commented Jan 31, 2019 at 18:22
  • 1
    @Zollie - Readbility improvements are fine as edits, but fixing code in the initial question should not be done. One of the reasons why the code wasn't working in the first place was due to a missing ) which you've fixed in the OP
    – Lodder
    Commented Jan 31, 2019 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.