2013-01-09 93 views
0

这部分是我需要得到的东西在我的网站的工作(我使用的是从wp-types.com工具集)显示JavaScript值在简码

[wpv-post-body id="3650"] 

我需要更换3650从短码在我的网址值:新券/ parent_lead_id = 3788

所以我跟着这个脚本,使它可以将值从URL

<script> 
    function getParam(name) 
{ 
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
var regexS = "[\\?&]"+name+"=([^&#]*)"; 
var regex = new RegExp(regexS); 
var results = regex.exec(window.location.href); 
if(results == null) 
    return ""; 
else 
return results[1]; 
} 

var frank_param = getParam('parent_lead_id'); 
    document.write(frank_param) 
</script> 

复制输出是如3788

问题是,我不能将这段代码放在短代码中,因为它不起作用。

由于不支持php:我们不能只输出。我还可以使用其他什么方法?

+0

任何人都可以帮忙:d –

回答

0

我不明白......我只是做了一个简码是执行的Javascript,并使用PHP养活的JS用URL查询无功...

/** 
* Usage: [alert] 
*/ 

add_shortcode('alert', 'alert_shortcode_so_14229381'); 

function alert_shortcode_so_14229381($atts, $content = null) 
{ 
    if(!isset($_GET['msg'])) 
     return; 

    $alert = $_GET['msg']; 
    $html = "<script>alert('{$alert}');</script>"; 
    return $html; 
} 

alert shortcode