URL-Encode javascript

时间:2013-04-18 14:09:01

标签: javascript html

我正在尝试url-encode ...我该怎么办?这种语法错了......

这是我的代码:

   <div class="post-btn-share">
<div class="addthis_toolbox addthis_default_style">
    <div class="float-all">
        <script>
            var url = urlencode('http://mypage.com/visualizar_foto.php?img=55&user=2&xx=');
            alert(url);
            </script>
        <iframe src="http://www.facebook.com/plugins/like.php?href=" + url + "&send=true&layout=standard&width=300&show_faces=true&action=like&colorscheme=light&font&height=80" frameborder="0" style="border:none;" scrolling="no" width="320" height="240"></iframe>
        <div class="float-all">

        </div>
        <div class="float-all">

        </div>
    </div>

2 个答案:

答案 0 :(得分:2)

尝试:

var url = encodeURIComponent('http://mypage.comvisualizar_foto.php?img=55&user=2&xx=');

答案 1 :(得分:0)

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode('http://mypage.com/visualizar_foto.php?img=55&user=2&xx='); ?>&send=true&layout=standard&width=300&show_faces=true&action=like&colorscheme=light&font&height=80" frameborder="0" style="border:none;" scrolling="no" width="320" height="240"></iframe>