Link to home
Start Free TrialLog in
Avatar of thedeal56
thedeal56

asked on

Javascript executing slow in IE8

I have some javascript that appears to run very slowly when executed in IE8.  The script checks for which browser is being used, and then it builds the contents of a popup window accordingly. Here is a link to the site where the script is running:

http://www/trafficcam.aspx?ekmenu=cam&id=traf

How can I fix this slow-down?  Let me know if I need to provide any additional info.  Thanks for reading.
<script language="javascript" type="text/javascript" >

        function camName(camnumber) {
            switch (camnumber) {
                case 1:
                    camname = "Broad & Mercury";
                    break;
                case 2:
                    camname = "Broad & Church";
                    break;
                case 3:
                    camname = "Broad & Main";
                    break;
                case 4:
                    camname = "Broad & West College";
                    break;
                case 5:
                    camname = "I-24 & Old Fort";
                    break;
                case 6:
                    camname = "Old Fort & Chaffin";
                    break;
                case 7:
                    camname = "Old Fort & Bridge";
                    break;
                case 8:
                    camname = "Old Fort & Kings Hwy";
                    break;
                case 9:
                    camname = "NW Broad & Monte Hale";
                    break;
                case 10:
                    camname = "NW Broad & Thompson";
                    break;
                case 11:
                    camname = "Memorial & Lokey";
                    break;
                case 12:
                    camname = "Memorial & Clark";
                    break;
                case 13:
                    camname = "Memorial & Northfield";
                    break;
                case 14:
                    camname = "Church & CSX RR";
                    break;
                case 15:
                    camname = "Church & Middle Tennessee Blvd";
                    break;
                case 16:
                    camname = "Church & I-24";
                    break;
                case 17:
                    camname = "Church & Warrior";
                    break;
                case 18:
                    camname = "Church & Calumet";
                    break;
                case 19:
                    camname = "Church & Barfield";
                    break;
                default:
                    camname = "";
                    break;
            }
            return (camname);
        }

        function camOpen(camnumber, camactive) {
            if (typeof camwin != 'undefined') { camwin.close(); }
            camwin = window.open("", "Camera", "toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=370,height=280");
            var vidserv = Math.round((camnumber / 4) + .49);
            var cam = camnumber % 4;
            if (cam == 0) { cam = 4; }
            var ImageResolution = "352x240"; var DisplayWidth = "352"; var DisplayHeight = "240";
            var File = "axis-cgi/mjpg/video.cgi?resolution=" + ImageResolution + "&duration=60";
            var output = "";
            var nooutput = "";
            var camname = camName(camnumber);
            var Camera = cam;
            
            var BaseURL = "http://traf" + vidserv + ".murfreesborotn.gov/";
            if (Camera != "") { File += "&camera=" + Camera; } output = '<html><head><title>Camera ' + camnumber + '</title></head><body><font size="2" face="Verdana, Arial, sans-serif"><STRONG>' + camname + '</STRONG></font><br>';
            if ((navigator.appName == "Microsoft Internet Explorer") && (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k")) {
                output += "<OBJECT ID=\"CamImage\" WIDTH="
                output += DisplayWidth;
                output += " HEIGHT=";
                output += DisplayHeight;
                output += " CLASSID=CLSID:917623D1-D8E5-11D2-BE8B-00104B06BDE3 ";
                output += "CODEBASE=\"";
                output += BaseURL;
                output += "activex/AxisCamControl.cab#Version=1,0,2,15\">";
                output += "<PARAM NAME=\"URL\" VALUE=\"";
                output += BaseURL;
                output += File;
                output += "\"> <BR><STRONG>Axis ActiveX Camera Control</STRONG><BR>";
                output += "The AXIS ActiveX Camera Control, which enables you ";
                output += "to view live image streams in Microsoft Internet";
                output += " Explorer, could not be registered on your computer.";
                output += "<BR></OBJECT>";
            }
            else {
                output = "<IMG SRC=\"";
                output += BaseURL;
                output += File;
                output += "&dummy=garb\" HEIGHT=\"";
                output += DisplayHeight;
                output += "\" WIDTH=\"";
                output += DisplayWidth;
                output += "\" ALT=\"Moving Image Stream\">";
            }
            output += "</center></body></html>"
            nooutput += "<center><html><table><tr><td style=\"color:red;\">This video is currently unavailable.</td></tr></table></html></center>";
            
            if (camactive == 0) { camwin.document.write(nooutput); }
            else {
                camwin.document.write(output);
            }
        }
    </script>

Open in new window

Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Avatar of gksinghiet
gksinghiet

In a nutsell you have to run folloing command from command prompt and restart your system:
regsvr32 actxprxy.dll

Unfortunatelly you cannot tell this to your users.
Avatar of thedeal56

ASKER

Thanks for the fast replies.  I checked out your suggestions, but they appear to focus on the client side.  I was hoping there would be a way that I could alter my script to make it run faster.  If this is a browser problem and not script related, then I guess I'll just have to let it go.  What do you think? Should I totally rule out a scripting solution?
Just for the record, I tried out regsvr32 actxprxy.dll, and it's still slow.  
try to print timestamp before and after the method to see which one is taking more time
After looking at it a bit more, I noticed that the problem seems to be with the actual opening of the popup window.  I searched around on this specific issue, and others seem to have experienced it.  I will post back when I know more.
I tried just running this in IE8, and the new window was slow to open.  Would you mind running that script to see if you get the same problem?

<script>
window.open();
</script>
hello thedeal56

Try :

<script>
alert("Fast!");
window.open("http://www.google.fr");
</script>

Regards
The alert pops up fast, but the window opening is still slow.
Remove you antivirus or antimalware and do a new test. You have a filter somewhere blocking internet traffic or popup window.
I'm not exactly sure what you mean.  I am able to see the window after after a shot period of time, so it's not being blocked.  I could see if maybe I had something doing a preliminary scan on all pop-up windows, but this would have to be something specific to IE8, because everything works fine in Firefox/Chrome.  In any case, I did disable my antivirus and I still got the same result.  
If you guys just make an html file and put this in it:

<script>
window.open();
</script>

Does the window open fast for you?  
Why : window.open();
And not :
window.open("http://www.google.fr");
or any other URL ?
Work VERY fast on IE8 for me. Don't just disable your antivirus, if possible remove it. What antivirus do you have ?
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry for the delay.  I'll answer your last posts in order:

I was just using a blank window as an example.  For me, it didn't matter if I put an actual URL; it was still slow.  

I tried it on a machine that did not have any antivirus on it, and it was still slow.  Trend Micro is the antivirus on my work machine.

I'll try disabling the popup blocker first thing tomorrow.  

It does sound like this problem will not be able to be resolved by simply altering the script a bit.  Especially since the window is opening fast for you.  The window open delay is only a couple of seconds, and it does still do what it's supposed to do once it pops up.  I think I'll just chalk this one up to my OCD and move on.  I really appreciate all the help on this.  
Thanks a lot for the points and your feedback!