2013-01-09 23 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