Iframe in moodle app 2.0

Iframe in moodle app 2.0

by Jaime Tapasco -
Number of replies: 2

Good morning, I have a problem, I researched in forums, documentation and I could not fix it.


I have the app Moodle 2.0 and want to put an Iframe and captures me the id of the url I want to load.



1) - When you give click here do not load the iframe I want to upload, the code that I put to the iframe carge me is: (<iframe class = "mm-iframe" type = "text / html" width = "640 "height =" 385 "ng-src =" {{url}} "> </ iframe>

 )


2) - What I want is that when I use {{url}} I load the url, capturing the corresponding id of each page.


3) - The iframe works for me when I put the complete url, for example:

<Iframe class = "mm-iframe" type = "text / html" width = "100%" height = "100%" ng-src = "http://google.com"> </ iframe>


4) - Also it works when I use the code with an <object>, for example:

<Object type = "text / html" data = "{{url}}" width = "100%" height = "100%" style = "overflow: hidden>

</ Object>


5) - This code what I have marked on the file (www / core / components / course templates / modcontent.html)


6) - the problem is that with <iframe> I work if I put the complete address, and does not work if I put {{url}}, that I need to capture me the id of each page, as if it does the <object>, I would use the latter label, but I tried to touch on Android and IOS and not working.

If I work if I use the <iframe>


In conclusion: I need is that this code <iframe class = "mm-iframe" type = "text / html" width = "640" height = "385" ng-src = "{{url}}"> </ iframe>, run me and load the page, then the <iframe> tag works correctly touch me.


I ask for help with this problem and I have not been able to solve, I'm not very skilled moodle even mobile, so I ask for help.


Beforehand thank you very much


if you need the source files, you can ask me, I send you gladly


Thank you

Average of ratings: -
In reply to Jaime Tapasco

Re: Iframe in moodle app 2.0

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Jaime,

if you want to use a dynamic URL in an iframe you need to mark that URL as "trusted", otherwise angular will block your URL. To do so, in your controller or service you'll have to inject $sce service and do something like this:

$scope.url = $sce.trustAsResourceUrl($scope.url);

I hope this fixes your problem smile

Kind regards,

Dani

In reply to Dani Palou

Re: Iframe in moodle app 2.0

by Jaime Tapasco -

Hi Daniel, thank you very much for answering,
when I put this code in my controller does not work, I'm a little inexperienced in this, because if not I'm putting it in the right place.
I can send you files app and you verify they are in the right place?

thank you