We are trying to inject html code into our page through a webblock. The html will only consist of two lines. One script line which will load a certain javascript file and the second line that will use the element created in the javascript file that we are loading.

This will load an image control which we use to display images. We are unable to load the control even if we can see the control in the page source.


Can anyone assist?


Below is the code that we are trying to load.

SyntaxEditor Code Snippet

"<script>
    $(document).ready(function() {
    alert('asdasd');
         document.write('<script type='text/javascript' src='https://unidevwww.smd360.co.za/Js/ThreeSixtyViewer/threesixty.widget.remote.js' data-app-id='app-id'><\/script>');
    });
</script>
<threesixty-widget id='ThreeSixtyViewer' style='width:400px;' data-capture='" + CaptureId + "'></threesixty-widget>"


Hi Rudolph Kalp,

Have you set the escape content property to No?

If you have done it, plz check if you have any JS error on the console. 

Br

Domingues wrote:

Hi Rudolph Kalp,

Have you set the escape content property to No?

If you have done it, plz check if you have any JS error on the console. 

Br


I have done this. But now it clear the whole page and throws an object object exception

Hey Rudolph,

The error is in this part:

document.write('<script type='text/javascript' src='https://unidevwww.smd360.co.za/Js/ThreeSixtyViewer/threesixty.widget.remote.js' data-app-id='app-id'><\/script>');

Within document.write you add a string, however let's take a look at your quotes.

'<script type='text/javascript' src='https://unidevwww.smd360.co.za/Js/ThreeSixtyViewer/threesixty.widget.remote.js' data-app-id='app-id'><\/script>'

In purple the part that is being formatted as a string.
Try changing to to the following to see if this works: 

document.write('<script type=text/javascript src=https://unidevwww.smd360.co.za/Js/ThreeSixtyViewer/threesixty.widget.remote.js data-app-id=app-id><\/script>');