PDA

View Full Version : VBScript in vBulletin


vinzphua
11-25-2005, 05:03 PM
Hi,

I'm using a VBScript to detect Flash Player on IE and some how it won't work properly. Unfortunately, the Javascript version used to detect Flash Player in other browsers don't work for IE, so I'm stuck with VBScript.

The VBScript does not seem to be running in vBulletin (I'm on 3.5.1). Can VBScript run in vBulletin? Or is it disabled? The code extracts are below.

The VBScript
<script language="VBScript" type="text/vbscript">
<!-- // Visual basic helper required to detect Flash Player ActiveX control version information
Function VBGetSwfVer(i)
on error resume next
Dim swControl, swVersion
swVersion = 0

set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))
if (IsObject(swControl)) then
swVersion = swControl.GetVariable("$version")
end if
VBGetSwfVer = swVersion
End Function
// -->
</script>
The script above is called later in the page by javascript:

for (i=25;i>0;i--) {
if (isIE && isWin && !isOpera) {
versionStr = VBGetSwfVer(i);
} else {
versionStr = JSGetSwfVer(i);
}
.
.
.


There are no problems with syntax. The same code in a clean page works properly. I've done troubleshooting and the VBScript only returns 0.

(Edit: Seems that I was talking to myself, so vBulletin automerged my followup posts here...)
I did more troubleshooting and found the the VBScript is running. CreateControl works but GetVariable is not returning the correct value. On a clean HTML file it works fine.

Any one has any idea why the GetVariable fails?

Thanks.

(Edit: here...)
I found the problem... PHP tried to replace $version in the line swVersion = swControl.GetVariable("$version").

The final source displayed on the browser is
swVersion = swControl.GetVariable("")

Now all I have to do is find out how to prevent that.

(Edit: and here...)
Hmmm... how come my post got automerged.

Anyway, in case anyone has this problem in the future, the solution is to escape the "$" with a backslash. so it becomes:

swVersion = swControl.GetVariable("\$version")

Works perfectly now.

Lionel
04-28-2006, 02:38 AM
I have the exact same problem, same code same everything. Unfortunately, escaping it does not solve it. A view source shows

swVersion = swControl.GetVariable("$version")

So $version is not read still. I know this is an old post, but any help will be greatly appreciated

I am at 3.07