Foren

Problem with javascript i get // <![CDATA[

Josep Palou, geändert vor 7 Jahren.

Problem with javascript i get // <![CDATA[

New Member Beiträge: 16 Beitrittsdatum: 20.06.16 Neueste Beiträge
Hi.

I want to load a javascript file in the Javascript section when i edit the pages . I want to put the src and i web that:

<script >
// <![CDATA[
src="url"

// ]]>
</script>

How can i make the pages load a script?

Thanks.
thumbnail
Samuel Kong, geändert vor 7 Jahren.

RE: Problem with javascript i get // <![CDATA[

Liferay Legend Beiträge: 1902 Beitrittsdatum: 10.03.08 Neueste Beiträge
What want is:
<script src="url" type="text/javascript"></script>
Josep Palou, geändert vor 7 Jahren.

RE: Problem with javascript i get // <![CDATA[

New Member Beiträge: 16 Beitrittsdatum: 20.06.16 Neueste Beiträge
Samuel Kong:
What want is:
<script src="url" type="text/javascript"></script>



Hi.

If i do that, i get that code in the website:

<script type="text/javascript">
// <![CDATA[
<script src="url" type="text/javascript"></script>
thumbnail
Samuel Kong, geändert vor 7 Jahren.

RE: Problem with javascript i get // <![CDATA[

Liferay Legend Beiträge: 1902 Beitrittsdatum: 10.03.08 Neueste Beiträge
You shouldn't do
<script type="text/javascript">
// <![CDATA[
<script src="url" type="text/javascript"></script> 

All you should have is
<script src="url" type="text/javascript"></script>
Josep Palou, geändert vor 7 Jahren.

RE: Problem with javascript i get // <![CDATA[

New Member Beiträge: 16 Beitrittsdatum: 20.06.16 Neueste Beiträge
Samuel Kong:
You shouldn't do
<script type="text/javascript">
// <![CDATA[
<script src="url" type="text/javascript"></script> 

All you should have is
<script src="url" type="text/javascript"></script>



You dont understand me.

I put the code in the javascript section of the theme. There i can put the javscript and i put what you say but in the webpage the code is with // <![CDATA[ .

The problem is i cant do < script src="".... i only want to load a js but i cant.
thumbnail
Julien Mourad, geändert vor 7 Jahren.

RE: Problem with javascript i get // <![CDATA[

Junior Member Beiträge: 78 Beitrittsdatum: 22.01.15 Neueste Beiträge
Josep,

The javascript section takes javascript code and not a file. In order to load a file, you'll need to do something like this:

var script = document.createElement("script");
script.type = "text/javascript";
script.src = "url";
document.body.appendChild(script);
Josep Palou, geändert vor 7 Jahren.

RE: Problem with javascript i get // <![CDATA[

New Member Beiträge: 16 Beitrittsdatum: 20.06.16 Neueste Beiträge
Julien Mourad:
Josep,

The javascript section takes javascript code and not a file. In order to load a file, you'll need to do something like this:

var script = document.createElement("script");
script.type = "text/javascript";
script.src = "url";
document.body.appendChild(script);


Hi thanks for your help.

I copied that code in the javascript section and i get the same thing:

<script type="text/javascript">
		// <![CDATA[
			var script = document.createElement("script");
2script.type = "text/javascript";
3script.src = "http://veritas.es/wp-content/js/gtm.js";
4document.body.appendChild(script);
		// ]]>
	</script>
thumbnail
Julien Mourad, geändert vor 7 Jahren.

RE: Problem with javascript i get // <![CDATA[

Junior Member Beiträge: 78 Beitrittsdatum: 22.01.15 Neueste Beiträge
What you see is fine, if you inspect your page with firebug or any web developer tool, you should see your script at the bottom of your page.
Josep Palou, geändert vor 7 Jahren.

RE: Problem with javascript i get // <![CDATA[

New Member Beiträge: 16 Beitrittsdatum: 20.06.16 Neueste Beiträge
Julien Mourad:
What you see is fine, if you inspect your page with firebug or any web developer tool, you should see your script at the bottom of your page.



Thanks again for your help.

I cant see the last line, i only see the CDATA...

I donwloaded firebug and i see the same as firefoox or chrome.
thumbnail
Julien Mourad, geändert vor 7 Jahren.

RE: Problem with javascript i get // <![CDATA[

Junior Member Beiträge: 78 Beitrittsdatum: 22.01.15 Neueste Beiträge
Are you getting any errors in the console? Also, can you provide a screenshot of where you're adding the javascript code, just to make sure we're on the same page.