• My plugin adds links with

    href="javascript:var t=window.open('a', 'b', 'c');"

    but what I end up with (in the output sent to the browser) is

    href="javascript:var t=window.open('a" , 'b', 'c');"

    That is, the first quote gets replaced by a double quote followed by a space. Of course, this breaks the javascript.

    Is there a way around this? I am using add_filter(‘the_content’,..), maybe there is a filter that is used after WordPress has finished transforming links?

    I found a post with the same problem, but no solution.

    This hasn’t been always like that, at least not when I first wrote and tested the code. However, I don’t know which version broke it.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter bAum

    (@baum)

    *bump*

    Hi,

    I just ran into this same problem today. So it’s now three of us waiting desperately for a solution ??

    What I am actually doing is adding a LiveZilla live-chat link, copying and pasting it directly from the LiveZilla link generator to the Edit Page page in the WordPress content management interface.

    I have tried that exact code in a plain HTML file and it works fine.

    Any help?

    Thanks,

    Luis

    Hi,

    I still don’t know why it happens, but I solved it by moving the window.open call into a script block, and just calling my funcion without parameters from the link:

    <script type="text/javascript">
    function openChat()
    {
        window.open('https://xxxxxx.com/livezilla/chat.php',
            '',
            'width=590,height=610,left=0,top=0,resizable=yes,menubar=no,location=no,status=yes,scrollbars=yes');
    }
    </script></p>
    <p><a href="javascript:openChat()"...

    I hope this helps!! ??

    Regards,

    Luis

    Hi, the current “solution” proposed doesn’t work at all for Bookmarklets. Not being able to showcase them in wordpress posts is very cumbersome for me. What’s the source of this problem and can the feature causing it be disabled? Hope someone replies.

    Best Regards

    Sorry to bump this. But i found a workaround that works with bookmarklets.

    Replace any ‘ single quote with the html counterpart ' .

    When the user drags the bookmarklet in its bar, the browser will translate the html value in the proper character and the code will work as intended from inside the user bar.

    Thread Starter bAum

    (@baum)

    Thanks ItsGC, this works for me! Unfortunately, it’s a bit unclear when reading it here in the form as & # 0 3 9 ; is rendered ‘.

    Blast it, i thought i added <code> but apparently i didn’t, Apologize and yeah that is the correct html code for the single quotes ^^

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Javascript in href: worpress replaces single quotes’ is closed to new replies.