View Full Version : How to input vbphrase in js
Easy5s.net
12-14-2012, 02:34 PM
We can use vbphrase in js file like?
$vbphrase or {vb: rawphrase}
I've tried two ways but not working
Since the js runs on the client browser, it won't have access to the vb variables. But what the vb code does is it creates js variables to makes some values available. If you look in the headinclude template you'll see a section like this:
var SESSIONURL = "{vb:raw session.sessionurl_js}";
var SECURITYTOKEN = "{vb:raw bbuserinfo.securitytoken}";
var IMGDIR_MISC = "{vb:stylevar imgdir_misc}";
var IMGDIR_BUTTON = "{vb:stylevar imgdir_button}";
//etc...
If you are including your js file in a vbulletin template (or in html that's output by a vbulletin "powered" script) you can do something similar. You might be able to use $template_hook['headinclude_javascript'] to include it in the headinclude template, depending on your situation.
Easy5s.net
12-14-2012, 03:26 PM
Here is a snippet of the file. js, and I want to use alternative vbpharse Thank
if(x.readyState==4&&x.status==200)
{
el.innerHTML='';
el=document.getElementById(id);
el.innerHTML=x.responseText;
document.getElementById(id2).innerHTML = "thank";
if (eval_str) eval(eval_str);
}
}
Where is that js file being included? It must be in a template or in html somewhere, right?
Easy5s.net
12-14-2012, 03:32 PM
Yes, it is located in one *.js file and I hook it to $template_hook ['headinclude_javascript']
OK, so I guess now you have something like:
$template_hook['headinclude_javascript'] .= '<script type="text/javascript" src="something.js" ></script>';
So add something to the beginning, like this:
$template_hook['headinclude_javascript'] .= '<script type="text/javascript">
var thanks_phrase = \'' . addslashes_js($vbphrase['thanks']) . '\';
</script>
<script type="text/javascript" src="something.js" ></script>';
then in your js file use thanks_phrase, like:
el.innerHTML=x.responseText;
document.getElementById(id2).innerHTML = thanks_phrase;
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.