...

View Full Version : Mozilla Layer not updating, MAC IE 5.1 Crash



Oakendin
12-20-2003, 03:56 AM
Hello,

I am trying to do something that would seem simple, but its taken my a couple hours of messing with variations of code that never seem to work.

The below code is for a pop up to close itself and update a parent layer. Works fine in PC IE 5.5+, but not in mozilla 1.4. On MAC 5.1, the update just crashes the browser altogether, parent and child windows. But works fine on MAC IE 4.5!

Here's my code, parent page code:


<html>
<head>
<title>Test Pop Up - Parent</title>

<script language="JavaScript1.2" type="text/javascript">
function winPopUp(winurl,winname,winprops) {
winpopup = open(winurl,winname,"width=400,height=400,scrollbars=auto,resizable=yes");
winpopup.top.focus();
}

function updateContents(div_tag,update_value){
if (document.all){
document.all(div_tag).innerHTML = update_value;
}else if (document.getElementById){
document.getElementById(div_tag).innerHtml = update_value;
}
}

function updateLayer() {
updateContents("test_layer","this is test text<br><br>");
}
</script>

</head>
<body bgcolor="#ffffff">
<h1>Test pop up Parent</h1>
<div style="position: relative;" id="test_layer"></div>
<br><br>
<a href="javascript:winPopUp('pop_up.asp','pop_up','');">Pop Up</a>
</body>
</html>


Pop Up page code:


<html>
<head>
<title>Test Pop Up</title>

<script language="JavaScript1.2" type="text/javascript">
function closeSelfAndUpdateParentLayer() {
if (window.opener != null) {
self.close();
window.opener.updateLayer();
}
//alert("foo");
window.close();
}
</script>

</head>
<body bgcolor="#ffffff">
<h1>Test pop up submit</h1>
<form action="pop_up.html" method=post name=testForm>
<input type=radio name="test" value="test">Test
<br>
<a href="javascript:closeSelfAndUpdateParentLayer();"><img src="submit.gif" border=0></a>
</form>


</body>
</html>


Thanks in advance.

ahosang
12-20-2003, 04:25 AM
Try changing some parts:
<a onclick="closeSelfAndUpdateParentLayer();return false" href="#">

and:
<a onclick="winPopUp('pop_up.asp','pop_up','');return false" href="#">

and:
function closeSelfAndUpdateParentLayer() {
if (window.opener != null) {
window.opener.updateLayer();
self.close();

}
//alert("foo");
window.close();
}

Oakendin
12-20-2003, 08:53 PM
Thanks ahosang. That solved the MAC IE 5.1 crash. However, in Mozilla 1.4, the parent layer is still NOT updating. Urgh. The mozilla javascript console doesn't have any errors and my debugger doesn't debug JS very well.

Oakendin
12-20-2003, 09:06 PM
WTF@@@##$#!!!!!

I figured out the Mozilla 1.4 bug and it works in Firebird 0.7 too. I went to this post:
http://www.codingforums.com/showthread.php?s=&threadid=30408

Took the function there and apply it to my document.getElementById area. Bam! works, i had return false in that section, but it didn't work. But calling another function with a return false works.

I am not sure as to why that logic works, but I am moving on now.

Thanks to all and hopefully the code will help some ppl out.

Parent HTML code:


<html>
<head>
<title>Test Pop Up - Parent</title>

<script language="JavaScript1.2" type="text/javascript">
function winPopUp(winurl,winname,winprops) {
winpopup = open(winurl,winname,"width=400,height=400,scrollbars=auto,resizable=yes");
winpopup.top.focus();
}

function updateContents(div_tag,update_value){
if (document.all){
document.all(div_tag).innerHTML = update_value;
}else if (document.getElementById){
changeLayerText(div_tag, update_value)
//document.getElementById(div_tag).innerHtml = update_value;
}
return false;
}

function updateLayer() {
updateContents("test_layer","this is test text<br><br>");
}

function changeLayerText(div_tag,txt){
document.getElementById(div_tag).innerHTML=txt;
return false;
}
</script>

</head>
<body bgcolor="#ffffff">
<h1>Test pop up Parent</h1>
<div style="position: relative;" id="test_layer"></div>
<br><br>
<a href="javascript:winPopUp('pop_up.asp','pop_up','');">Pop Up</a>
</body>
</html>


Child Pop Up HTML code:


<html>
<head>
<title>Test Pop Up</title>

<script language="JavaScript1.2" type="text/javascript">
function closeSelfAndUpdateParentLayer() {
if (window.opener != null) {
window.opener.updateLayer();
}
self.close();
}
</script>

</head>
<body bgcolor="#ffffff">
<h1>Test pop up submit</h1>
<form action="pop_up.html" method=post name=testForm>
<input type=radio name="test" value="test">Test
<br>
<a href="#" onclick="javascript:closeSelfAndUpdateParentLayer();return false;"><img src="submit.gif" border=0></a>
</form>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum