Javascript Show/Hide in Safari

K

Kush

Guest
Hi, I'm having trouble with the following JS in Safari:

Code:
function showhide(layer_ref,page,image_id,showhide) {
if (page=='comments') { 
	document.all.rightiframe.src='commentsframe.php?image_id=' + image_id;
}
if (page=='shoutbox') { 
	document.all.rightiframe.src='shoutboxframe.php';
}

if (showhide == 'yes') {
	if (state == 'visible') {
		state = 'hidden';
	}
	else {
		state = 'visible';
	}
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
	alert("1");
	eval( "document.all." + layer_ref + ".style.visibility = state");
	}
	if (document.layers) { //IS NETSCAPE 4 or below
	alert("2");
	document.layers[layer_ref].visibility = state;
	}
	if (document.getElementById && !document.all) {
	alert("3");
	maxwell_smart = document.getElementById(layer_ref);
	maxwell_smart.style.visibility = state;
	}
}
}

Not being a big Javascript user, I can't understand why this doesn't work in Safari? You can see the alerts I've put in... well none of them show up, so I've identified where my problems begin at least!

I've tested it on IE, Firefox and Opera for PC and it works no problem.

Any ideas? :dive:
 
Joined
Jun 11, 2003
Messages
4,915
Reaction score
68
Points
48
Location
Mount Vernon, WA
Your Mac's Specs
MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
Try changing state = 'visible' to state = '';
That might work for you.
 
OP
K

Kush

Guest
further investigation

I've been looking into this a bit more today and it looks like the following line causes the script to stop functioning:
Code:
document.all.rightiframe.src='shoutboxframe.php';

Anyonw know why Safari would choke on this?
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top