Click to See Complete Forum and Search --> : Cross browser functionality


drsmartman
04-15-2004, 05:39 PM
Having trouble getting some JS to work in different browsers. IE 5.5/6 and Netscape 7+ seem to work good.

I actually solved the functionality problem on this forum and am hoping to get some on the cross browser issue....the main problem is getting references to frame/window events and variables.....does the code below look okay? How to improve for universal compatibility (is there a best practice for calling/setting variables or events in another frame?)?

---part of script from mainWindow
parent.loc = new Array("link1","link2","link3");
parent.buyWindow.location.reload();
---

----part of script from main frame (parent frame)
<script language="JavaScript">

var loadedPage="0";
var loc = new Array();
var messageShown="false";
var onlineBuy="false";

function openUrls() {

if(loadedPage<loc.length) {

parent.buyWindow.location=loc[loadedPage];
loadedPage++;
}

if(loadedPage==loc.length && loc.length>0 && loadedPage>0 && messageShown=="false" && onlineBuy=="true"){


window.open("link");
messageShown="true";
}
}

</script>
---------

----frame source
<frameset rows="0,*">

<frame src="buy.html" name="buyWindow" onLoad="parent.openUrls()" NORESIZE>
<frame src="registration.php?cf=2" name="mainWindow">

</frameset>
------

Any help to get this working on other browsers is helpful....

Kor
04-16-2004, 03:10 AM
So... you want to acces a frame from another frame?

Better try using the reference:

top.frames['buyWindow'].location
instead of
parent.buyWindow.location

drsmartman
04-16-2004, 11:12 AM
Hi,

I tried the 'top' reference and several others. Everything works as planned with IE 6, Netscape 7.1 and others using both of our methods....

For some reason, Safari and IE 5.2 on Mac OS X do not take to this. I actually replaced everything in the openUrls() function with an alert() just to test that it could be accessed. Unsuccesful...

----frame source
<frameset rows="0,*">

<frame src="buy.html" name="buyWindow" onLoad="parent.openUrls()" NORESIZE>
<frame src="mypage.html"
name="mainWindow">

</frameset>
------

Note that I used self.top, self.parent, parent and top to get the function openUrls() to execute in addition to parent.openUrls() listed above.....below is the slimmed down function...

<script language="JavaScript">
funtion openUrls(){
alert("function accessed");
}

</script>

This is odd....I'm sure I never would have noticed this except that our office is 50% Mac OS X users.

any other ideas? or, am i accesing the "MAIN" frame/window in the worng way?

Many thanks!!!