Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 添加Javascript代码和URL语法_Php_Javascript - Fatal编程技术网

Php 添加Javascript代码和URL语法

Php 添加Javascript代码和URL语法,php,javascript,Php,Javascript,我想缩短用Javascript编写的社交共享按钮的URL。 剧本 社交共享脚本的部分代码 var methods = { init : function(options) { this.share.settings = $.extend({}, this.share.defaults, options); var settings = this.share.settings, networks = this.share.settings.n

我想缩短用Javascript编写的社交共享按钮的URL。 剧本

社交共享脚本的部分代码

var methods = {
    init : function(options) {
        this.share.settings = $.extend({}, this.share.defaults, options);
        var settings = this.share.settings,
        networks = this.share.settings.networks,
        theme = this.share.settings.theme,
        orientation = this.share.settings.orientation,
        affix = this.share.settings.affix,
        margin = this.share.settings.margin,
        pageTitle = this.share.settings.title||$(document).attr('title'),
        pageUrl = this.share.settings.urlToShare||$(location).attr('href'),
        pageDesc = "";

        $.each($(document).find('meta[name="description"]'),function(idx,item){
            pageDesc = $(item).attr("content");
        });

        // each instance of this plugin
        return this.each(function() {
            var $element = $(this),
            id=$element.attr("id"),
            u=encodeURIComponent(pageUrl),
            t=encodeURIComponent(pageTitle),
            d=pageDesc.substring(0,250),
            href;

            // append HTML for each network button
            for (var item in networks) {
                item = networks[item];
                href = helpers.networkDefs[item].url;
                href = href.replace('|u|',u).replace('|t|',t).replace('|d|',d)
                           .replace('|140|',t.substring(0,130));
                $("<a href='"+href+"' title='Share this page on "+item+
                    "' class='pop share-"+theme+" share-"+theme+"-"+item+"'></a>")
                            .appendTo($element);
            }

            // bind click
            $('.pop').click(function(){
                window.open($(this).attr('href'),'t','toolbar=0,resizable=1,status=0,width=640,height=528');
                return false;
            });


        });// end plugin instance

    }
调用PHP代码

$url=json_decode($short,TRUE);
echo $url['short'];
这是在这里做的,但我不知道怎么做

u=encodeURIComponent(pageUrl),

你有什么问题?你也不正确地使用了这个关键词。以后会出问题的。脚本不是我的。我对Javascript知之甚少。这就是为什么会有麻烦。希望缩短页面URL,并让缩短的URL在社交网站上共享。
u=encodeURIComponent(pageUrl),