Page 1 of 1
JavaScript document.write question
Posted: Fri Dec 17, 2004 1:01 pm
by WaldoMonster
I'm not so familiar with Javascript, so maybe it is a simple question.
I use overLIB JavaScript and I want to display the version number in my html/php page.
The version number is in the script like this
olInfo=new Info('4.10', 1)
How can I write the variable with document.write(??????)
Posted: Fri Dec 17, 2004 1:04 pm
by Joe
If I am right in saying that olInfo is a variable then try:
Code: Select all
document.write("<?php echo $olInfo; ?>");
Posted: Fri Dec 17, 2004 1:06 pm
by WaldoMonster
Joe wrote:If I am right in saying that olInfo is a variable then try:
Code: Select all
document.write("<?php echo $olInfo; ?>");
var olInfo=new Info('4.10', 1); is in the JavaScript.
Sorry if I was unclear.
Posted: Fri Dec 17, 2004 1:07 pm
by Joe
Posted: Fri Dec 17, 2004 1:14 pm
by WaldoMonster
This is working:
Code: Select all
<script language="JavaScript" type="text/javascript">
var olInfo='version xyz';
document.write(olInfo);
</script>
This is not working and I need to write: var olInfo=new Info('4.10', 1);
Code: Select all
<script language="JavaScript" type="text/javascript">
var olInfo=new Info('4.10', 1);
document.write(olInfo);
</script>
Posted: Fri Dec 17, 2004 1:22 pm
by Joe
Has olInfo been defined by a function?. By looking at your code I think using:
Code: Select all
<script language="JavaScript" type="text/javascript">
var olInfo='4.10';
document.write(olInfo);
</script>
Would work the exact same.
Posted: Fri Dec 17, 2004 1:30 pm
by WaldoMonster
I'm not so familiar with Javascript, Is this helpfull?
var olLoaded=0;
var pmStart=10000000;
var pmUpper=10001000;
var pmCount=pmStart+1;
var pmt='';
var pms=new Array();
var olInfo=new Info('4.10', 1);
var FREPLACE=0;
var FBEFORE=1;
var FAFTER=2;
....
function Info(version, prerelease) {this.version=version;this.prerelease=prerelease;
this.simpleversion=Math.round(this.version*100);this.major=parseInt(this.simpleversion/100);this.minor=parseInt(this.simpleversion/10)-this.major * 10;this.revision=parseInt(this.simpleversion)-this.major * 100-this.minor * 10;this.meets=meets;}
Posted: Fri Dec 17, 2004 1:39 pm
by Joe
It appears there is something wrong with the Info() function. If you try:
Code: Select all
<script language="javascript" type="text/javascript">
function Info(version, prerelease)
{
this.version=version;
this.prerelease=prerelease;
this.simpleversion=Math.round(this.version*100);
this.major=parseInt(this.simpleversion/100);
this.minor=parseInt(this.simpleversion/10)-this.major * 10;
this.revision=parseInt(this.simpleversion)-this.major * 100-this.minor * 10;
this.meets=meets;
}
document.write(new Info('4.10', 1));
</script>
You are resulted in a js error?.
Posted: Tue Jan 18, 2005 8:27 am
by WaldoMonster
I found the solution.
Obvious it was very simple.
Code: Select all
<script type="text/javascript">
<!--
document.write(olInfo.version);
// -->
</script>