Forum Moderators: open

Message Too Old, No Replies

Javascript problems in Firefox

"transferview is not defined"?

         

Godzero

2:51 am on May 15, 2007 (gmt 0)

10+ Year Member


hey, im having trouble with a page im making for my online portfolio. The javascript im using only seems to work in IE, but in Firefox it does nothing. When i look at the Firefox error console it says "transferview is not defined". Im afraid im rather a noob when it comes to javascript, and i have no idea what its even refering too.

maybe someone here can clear it up for me. The script is just to expand an image window.

heres the code:

</head>

<script language=JavaScript>

var width,height,title
var image,ext
var cond1,cond2
function transferview(image,width,height,title) {
if (width==0) cond1=" "
else cond1="width="+(width)+"";
if (height==0) {cond2=" "};
else {cond2="height="+(height)+""};

var s1 ="<img src='"+image+"' border='0' style='position:absolute; top:0px; left:0px'>"

ImageWindow=window.open("", "newwin"+width,"toolbar=no,scrollbars="+scroll+",menubar=no,"+cond1+","+cond2);
ImageWindow.document.write(s1)
ImageWindow.document.write("<title>")
ImageWindow.document.write
(title)
ImageWindow.document.write("</title>")
ImageWindow.document.close()
}
</script>

<body bgcolor="#000000" background="Phoenix3.png" text="#FFFFFF" link="#FFFFFF">
<div align="left">
<table width="75%" border="0">
<tr>
<td width="9%" height="70"> <div align="right"><a onClick="javascript:transferview('pics/Cameleon.jpg',720,576,'Cameleon')" href="javascript:;"><img src="pics/Cameleonsmall.jpg" width="75" border="1"></a></div></td>

...

[1][[b]edited by[/b]: Godzero at 2:52 am (utc) on May 15, 2007][/1]

daveVk

4:31 am on May 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try moving </head> to after </script>, that is include script with head section.

Godzero

9:25 am on May 15, 2007 (gmt 0)

10+ Year Member



tried that, didnt seem to have any effect. Still works in IE but not in firefox?

[edited by: Godzero at 9:29 am (utc) on May 15, 2007]

daveVk

12:21 pm on May 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if (height==0) {cond2=" "};
else {cond2="height="+(height)+""};

to

if (height==0) {cond2=" "}
else {cond2="height="+(height)+""};

maybe

Dabrowski

1:01 pm on May 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dave is right, the <script> should definately be contained inside your <head>.

The declaration need to change:

<script language=JavaScript> 
<script type='text/javascript'>

Language isn't used any more.

if (width==0) cond1=" "
else cond1="width="+(width)+"";
if (height==0) {cond2=" "}; // WELL SPOTTED
else {cond2="height="+(height)+""};

See that semi-colon? It shouldn't be there, or the one on the next line, it's either a syntax error, or it's ending the if statement before the else, making the else an error. Also as it's only 1 line, you don't need the {}'s at all.

if (width==0) cond1=" ";
else cond1="width="+(width)+"";
if (height==0) cond2=" ";
else cond2="height="+(height)+"";

IE probably just ignores them, but that should have fixed it.

Godzero

2:22 pm on May 15, 2007 (gmt 0)

10+ Year Member



wow, thanks for your quick response's. That sure did the trick, its working fine now.

thanks for all your help.

Godzero.