Crazy JScript/IE ?

Why would this work on my machine –

alert(“test”);
if (parent.MapFrame.useZoomIn) {
document.write('Usezoomin is true’);
}

And this fail -

//alert(“test”);
if (parent.MapFrame.useZoomIn) {
document.write('Usezoomin is true’);
}

In the second example, alert(parent.MapFrame.useZoomIn) returns ‘undefined’. The only difference in the code is the alert is commented out.

I’m using IE 6.0.28. It works fine on co-workers machine running same IE (with same options) and operating system.

It works fine with NetScape.

I have reinstalled IE.

Thanks

Correction, sometimes it works correctly with Netscape. Maybe 1 in 10.

I had to support Javascript on 3 versions of Netscape, 2 versions of IE and 2 versions of a Mac browser. I couldn’t believe the things that would work on one browser and not another, simple things like arrays. I had a JS book that laid out what was supported by each browser and what was deprecated. JS development can be very frustrating indeed.

The first thing I would do is delete that line, then type it in again, making sure absolutely that is spelled correctly.

I have.

Now I have stacked this two exact lines on top of each other -

alert(parent.MapFrame.useZoomIn);
alert(parent.MapFrame.useZoomIn);

The response I get is this -

First alert - ‘undefined’
Second alert - ‘true’

Hmm, might be some funky object-creation thing going on. Maybe try to put an “alert();” way at the beginning of your script. That will create the object but not display anything.

I figured it out.

This code -

if (parent.MapFrame.useZoomIn) {
document.write('Usezoomin is true’);
}

Is in a frame that loads before MapFrame loads. So it seems that it was looking for variables that where not loaded yet. The alert, paused things just long enough to get those variables loaded.

I put an onLoad event in the <frameset> tag that refreseses the frame that needs those variables.

Does that make sence? Anyway, it seems to work.

Thanks

Where is this code? There may be a problem using document.write() in the <head> before the body is created, and the alert() just causes the document.write() to be delayed long enough for the body to be created.

That’s a wild guess.

whoops, looks like you already figured it out.

Javascript AND frames? A true warrior you are :slight_smile:

Try this:

var mapFrame=parent.getElementById(“MapFrame”);
if (mapFrame.useZoomIn) {
document.write('Usezoomin is true’);
}

I think that’s the correct syntax. I’m currently writing a web app that has a main page with two IFrames, and each IFrame itself has another IFrame that is used to do remote procedure calls to the web server. We have dynamic lists of data on the pages, so when a user adds a new object, we load a command page into the Iframe which calls a servlet. The servlet responds with a block of data. The onload() handler in the Iframe triggers a Javascript method in the parent container which parses the document for the data, and then updates the list on the page using DHTML.

Lots of fun keeping it all straight!

Hiya cc,

Can I take that as a compliment :slight_smile:
or :frowning:

I don’t think I have any choice but to use frames with this app. This will be my second web app. First one is VB driven (first VB, HTML and JS for me, about 3000 lines of code[many of that is comments that start with “WTF”]), dynamically feeding data (pushing out .gif, HTML and JS) drawing data from informix, and spatial data from both Win and UNIX servers off a WAN and LAN.

I think we will be dropping informix and going to SQL server. Someday.

What’s that saying, “been doing so much for so little for so long that I can now do anything with nothing”.

It’s GIS (geographic info systems).

I’m switching it over to an ASP VBscript solution for the informix calls. That’s a long story. Mostly tied into our GIS solution, and the engine that makes the maps.

Sam - Thanks for the tip, I will look into it. I currently have so much old code that I have to keep alive that it’s real tough to keep up with new stuff. Funny, isn’t it, won’t die unless someone kills it. I’ll remember that at our next staff meeting.

Hello enipla.

I just remember all the headaches I had trying to support JS under multiple versions of multiple browsers. Then with the added complications of Frames on top of that, I just had to roll my eyes a bit here :slight_smile:

Any time I hear Frames I think of “you want fries with that?” because of all the sites that used to prompt you about displaying in Frames, or not. Maybe I was just lazy, or maybe I got totally frustrated with what was supported by what browser, I usually took the “multiple browser window” approach.

Pushing GIS data from Informix to Frames, that’s hot stuff. I was going to take a geology class on map making this semester. Maybe next semester it will be offered at night? Seems like GIS a really hot field right now.

Switching from Informix to SQL Server? I always remembered Informix as being lean-and-mean and SQL Server as being kind of a toy that didn’t work very well in real-world applications. But I am old an gray, maybe things have changed in the last few years.

Good luck with your development, sounds like an interesting application. Now, I’m off to read my book: C# / .Net for dummies :smiley:

Thanks cc,

The crazy thing about this problem was that it was only happening on 2 computers. Other boxes with the same browser/OS where fine. Really strange. It must have been related to speed and network config. Some of the machines would get the frame loaded fast enough, some wouldn’t. Crazy. I thought it was an IE problem until some of the machines that ‘worked’ started failing.

Spatial (GIS) data is pretty amazing stuff. Everything has one thing in common. It has a location. So, with the right design, you can relate just about anything.

Great on the GIS class. You will almost certainly be using ESRI software - www.esri.com. Check it out.

Informix was bought by IBM - bhu by. It kinda looks like it is gonna die a slow death.

I’m 42 and feeling like a bit of a dinosaur, looks like VB .net is next for me.

Thanks again everyone.

This Pretty much sums it up for me -

I’ve had the code-loading-before-the-variables problem, too. My solution was to make the entire code a function which got called from an onLoad in the <BODY> tag.

jjimm -

The body of the Main frame calling script? The one that defines the frames?

I was modifying a canned app and moved the frame that needed the variables up one heiarchy to a different frameset and frame. That’s when things started to go in the tank. It surprises me that that one level screwed things up so much.

In other words.

The frameset that needed the variables started off 1 frameset level above the frameset that provided them. I moved it to two levels above. Just enough to ruin my day I guess.

Anyway, looks like you have a good idea too. Thanks.

Well specifically, the last frame to load calls the function (which can be in the parent frameset page if you want).