Click to See Complete Forum and Search --> : constant error in code


rharmer
09-23-2003, 01:37 PM
The following code doesn't work as intended. the first two links open correctly, but the second two don't open and you get a constant error..any clues?

...code entered in the head section.

<SCRIPT LANGUAGE="JavaScript">

function twin01() {
var newWindow01 = open("images/Redon03_01.jpg", "Redon03_01", "toolbar=no,status=no,location=no,menubar=no,directories=no,width=640,height=480,top=50,left=100");
}

function twin02() {
var newWindow02 = open("images/Redon03_02.jpg", "Redon03_02", "toolbar=no,status=no,location=no,menubar=no,directories=no,width=640,height=480,top=50,left=100");

}

</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">

function twin03() {
var newWindow03 = open("images/Redon03_03.jpg", "Redon03_03", "toolbar=no,status=no,location=no,menubar=no,directories=no,width=640,height=480",top=50,left=100");

}
function twin04() {
var newWindow04 = open("images/Redon03_04.jpg", "Redon03_04", "toolbar=no,status=no,location=no,menubar=no,directories=no,width=640,height=480",top=50,left=100");
}

</SCRIPT>

...code entered in the body section.

<FORM>
<INPUT TYPE="Image" SRC="images/Redon04_01.jpg" onClick="twin01()" ALT="Redon Image 1">
<INPUT TYPE="Image" SRC="images/Redon04_02.jpg" onClick="twin02()" ALT="Redon Image 2">
<INPUT TYPE="Image" SRC="images/Redon04_03.jpg" onClick="twin03()" ALT="Redon Image 3">
<INPUT TYPE="Image" SRC="images/Redon04_04.jpg" onClick="twin04()" ALT="Redon Image 4">
</FORM>

Charles
09-23-2003, 01:43 PM
Don't forget about those people who eschew JavaScript.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>

<div>
<a href="images/Redon03_01.jpg" onclick="window.open(this.href, 'Redon03_01', 'width=640,height=480,top=50,left=100'); return false"><img src="images/Redon04_01.jpg" alt="Redon Image 1"></a>

<a href="images/Redon03_02.jpg" onclick="window.open(this.href, 'Redon03_02', 'width=640,height=480,top=50,left=100'); return false"><img src="images/Redon04_02.jpg" alt="Redon Image 2"></a>

<a href="images/Redon03_03.jpg" onclick="window.open(this.href, 'Redon03_03', 'width=640,height=480,top=50,left=100'); return false"><img src="images/Redon04_03.jpg" alt="Redon Image 3"></a>

<a href="images/Redon03_04.jpg" onclick="window.open(this.href, 'Redon03_04', 'width=640,height=480,top=50,left=100'); return false"><img src="images/Redon04_04.jpg" alt="Redon Image 4"></a>
</div>

jalarie
09-23-2003, 01:45 PM
The non-working pair each have an extra quote-mark immediately after the "height=480" which needs to be deleted.

rharmer
09-23-2003, 01:53 PM
cheers!

Charles
09-23-2003, 01:56 PM
Originally posted by rharmer
any ideas on fixing this code without reverting to the <a> tags? If you fix the ccode without reverting to the <a> tags then it will fail for the 13% of users who do not use JavaScript and the teeming masses who have disabled popups. The method I demonstrated above will keep the page working on all browsers.

rharmer
09-23-2003, 02:07 PM
thanks for that, will try.

also, the image link that opens up don't have the top left corner fixed into the top left of the new window, there is a gap. have since changed the window dimensions from 640x480 to a smaller number of 438x299. does the height and width need to fit into a standard format?

can you put a bit of coding like ...LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 into the opened window?

Charles
09-23-2003, 02:11 PM
To make matters worse, when you specify the window size you are specifying the outer dimensions. You have no way of knowing how much space the sides of the window are going to take up. Your best bet is to set each of those images in a separate web page, say against a black background and perhaps centered.

rharmer
09-23-2003, 02:16 PM
cheers, will do!