Support » Fixing WordPress » When creating new page with javascript amperstands being replaced with &

  • Using version 2.1.3. Issue is when I try to create a page that includes javascript the & is being replaced with &. However, if I include the same code on the sidebar I do not have the problem and I get the proper info displayed.

    Example line:
    <script type="text/javascript" src=""></script>

Viewing 4 replies - 1 through 4 (of 4 total)
  • OK, first post and I made a couple of mistakes. The & is being replaced with &amp; is how it should have read.

    Sorry about that folks.


    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Yes, it will be replaced with &amp;, because that’s what it’s supposed to do.

    Straight ampersand symbols are actually invalid in both HTML and XHTML. Yes, even in links or scripts or img tags. They are supposed to be replaced with the &amp; text instead.

    Don’t worry, the browser will deal with it correctly.

    BTW, the fact that it’s *not* getting replaced on your sidebar is the problem here. Although it’s not necessarily a “bug”, because it’s not going through the filters that the post/page content goes through to correct these sort of things.

    You should change your sidebar to use &amp; as well, to be valid and correct.

    Your right, I am seeing a some other thing that are getting changed. Not sure if this is supposed to happen or not.

    This is what I trying to put on the page.

    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=";callback=GRC_p(%7Bc%3A'blue'%2Ct%3A''%2Cs%3A'false'%7D)%3Bnew%20GRC"></script>

    This is what is it getting changed to.

    <script src="" type="text/javascript"></script> <script src=";callback=GRC_p(%7Bc%3A\'blue\'%2Ct%3A\'\'%2Cs%3A\'false\'%7D)%3Bnew%20GRC" type="text/javascript"></script>

    In the side bar this is what code looks like now.

    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=";callback=GRC_p(%7Bc%3A'blue'%2Ct%3A'F1%20Racing%20News'%2Cs%3A'false'%7D)%3Bnew%20GRC"></script>

    The site is if you want to see for yourself.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    The single quotes that you’re putting in the link are getting backslash escaped, but other than that it looks like the code is basically unaltered. Find a workaround for the quote escaping. This could be a PHP setting that is causing the single quotes to be escaped.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘When creating new page with javascript amperstands being replaced with &’ is closed to new replies.