IE7 expected end of statement after VBScript

Hi

For some reason I can’t work out in IE7 I get a script error when the page loads. I have stripped everything out except the vbscript block that detects the plugin to isolate the problem.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <script language='VBScript'>
        function detectUnityWebPlayerActiveX
            on error resume next
            dim tControl
            dim res
            res = 0
            set tControl = CreateObject("UnityWebPlayer.UnityWebPlayer.1")
            if IsObject(tControl) then
                res = 1
            end if
            detectUnityWebPlayerActiveX = res
        end function
    </script>
</head>
<body>
    <button onclick="alert('here');">test</button>
</body>
</html>

All I’m doing to create the error is to add any html element with an onclick event.

I think it has something to do with IE thinking the event is server side perhaps?

Works fine in firefox.

I would like to embed the unity3d plugin in a website, but cant get psat this error.

thanks for any help.

ok, I got it sorted, I kind of remembered this from flash detection.

By placing the vb in an external file it works.

    <script type="text/javascript" src="set_vars.js"></script>
    <script type="text/vbscript" src="unity_test.vb"></script>

In set_vars.js I do setup for the page which includes

var unityFound = 0;

then in unity_test.vb

on error resume next

If (IsObject(CreateObject("UnityWebPlayer.UnityWebPlayer.1"))) Then
    unityFound = 1
Else
    unityFound = 0
End If

Now later on the page where I have onclick events I don’t get errors.

I’m not sure if this is specific to my environment, I would have thought someone would ahve come across it before.

Anyway, it’s all good

http://www.newcastlecreativemedia.com.au/SignPost/

And here’s how this works (real simple):
http://forum.unity3d.com/viewtopic.php?p=110726#110726

Cheers

Ah, not quite.

Now it works fine on PC, but not on Mac.

It seems like

	on error resume next
	dim unityControl
	set unityControl = CreateObject("UnityWebPlayer.UnityWebPlayer.1")
	If (IsObject(unityControl)) Then
            unityFound = 1
	Else
	    unityFound = 0
	End If

results in unityFound being 0

but the regular code does pretty much the same thing, only difference is that it’s called as a function rather than being set as the page loads.

Any ideas?