By Juno on
I will publish a full HTML page.There are some inline JavaScript code in page. Visit this page, inline JavaScript doesn't work. I view page source,find inline JavaScript is Below:
<script type="text/javascript"><![CDATA[
]]><!--//--><![CDATA[// ><!--
alert('test');
//--><!]]><![CDATA[
]]></script>
I don't understand why drupal add '<![CDATA[]]><!--//--><![CDATA[// ><!--' in there, it makes inline JavaScript doesn't work. If drupal add '<!--//--><![CDATA[// ><!--' in inline JavaScript,it works. In addition ,I find drupal's inline JavaScript codes are added correct CDATA.
Below:
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, {"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"javy","theme_token":"Kj-.....
//--><!]]>
</script>
Anybody help me?
Thanks a lot~
Comments
The CDATA won't stop your
The CDATA won't stop your script from working, and in fact will keep it working in some situations where it wouldn't (which is why it's there). There is likely an error in some javascript somewhere.
Install the firebug add-on for firefox, and test it there. Firebug will show you all the javascript errors and help you track down your issue.
edit: it may also help if you show us how you are adding your javascript. You may be adding it incorrectly.
Contact me to contract me for D7 -> D10/11 migrations.
Thanks for commenting. I
Thanks for commenting. I know CDATA's meaning,but drupal adds incorrectly CDATA. A new page put
It don't alert.
You're right, that doesn't
You're right, that doesn't look right. So again, how are you adding your javascript?
Contact me to contract me for D7 -> D10/11 migrations.
Did you solve the Problem? I
Did you solve the Problem? I have a similar problem when trying to add inline Javascript. Adding JS Libraries in the header is no problem. I tried various methods, more or less like this:
or this:
from the author of the associated js library i got this snippet:
in script tags of course.
I would appreciate any hint or help...
...it would help if you also
...it would help if you also told us what the problem is, and what errors you are receiving.
Contact me to contract me for D7 -> D10/11 migrations.
i just found out the script is active
Thank you for your prompt reply.
I just found out in FireBug that my JavaScript actually seems to be executed. For some other reason it doesn´t work. Maybe there is a problem with the way drupal is adding the class attributes myPageFlip and jPageFlip to the divs?
What i am trying to do is getting the jPageFlip JavaScript to run.
As you can see on http://www.jpageflip.de/ there is a library needed and the plugin is activated the following way:
I can add the library as a file without problems through a PHP Code text format custom Block and am trying to add the needed inline code the same way:
what i get in the header is this:
the // seem to uncomment the multiline comment start and end which was quite confusing...
Anyways, thank you again and if you have any suggestions how to debug my problem that would be great :)
Regards,
Markus
You still haven't mentioned
You still haven't mentioned what the problem is.
Contact me to contract me for D7 -> D10/11 migrations.
Check this out:
Check this out: https://drupal.org/update/modules/6/7#javascript_compatibility
lunk_rat is Acquia Certified Grand Master
Missing javascript in header...
I had the same issue. All Javascript code was suddenly hidden inside CDATA comments...
I fixed the problem by adding < script type="text/javascript" src="path_to_your_js_file> in the header (by editing html.tpl.php file) or right before the javascript code in the content.
The problem started after a theme update. The new html.tpl.php file erase the old one. (lost some CSS too)
Morale: Always make sub-theming or at least keep up-to-date backups.
While CDATA isn't really
While CDATA isn't really necessary anymore, it shouldn't break your JavaScript. Are you sure your problem wasn't somewhere else?
Contact me to contract me for D7 -> D10/11 migrations.
I have a similar problem,
I have a similar problem, Drupal adds the CDATA tag to my script, however google search console send me an alert that there is an error because of that, what can I do to remove it? I already tried with the examples above but it still doesn't work.