popup error (javascript)

B

Ben Wan

I got 2 error from the following code below...
1. I couldn't load up the picture since the picture is at
(C:\company\image\largePic.jpg)
2. I got a page error in my 'index.html' when calling popup(x,x,x) for the
2nd time.

The code are as followed.
Can anyone help please? Thank you very much~~

Ben


~~~~~~~ INDEX.HTML ~~~~~~~~ (c:\company\image\index.html)

<html><head><title>Megatone Inc.</title></head>
<style language='javascript'>
<!--
function popup(picName, chatWidth, chatHeight) {
popup = window.open('/popup.html','popup','left=50,top=50');
var loadedPic = picName;
while(popup.document.readyState != "complete") {}
popup.resizeTo(chatWidth,chatHeight);
popup.document.images.src=loadedPic;
popup.focus();
};
//-->
</style></head><body>
<A href="javaScript:popup('largePic.jpg','750','392')"><IMG
src="smallPIc.jpg" align=center></A>
</body></html>



~~~~~~~ POPUP.HTML ~~~~~~~~ (c:\)

<html><head><title>Megatone Inc.</title></head>
<BODY marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>

<table width='100%' height='100%' border=0><tr><td align='center'
valign='center'>
<img name='images' src='' alt='Loading Picture'>
</td></tr></table>

</BODY><HTML>
 
L

Lasse Reichstein Nielsen

Ben Wan said:
<style language='javascript'>

<style type="text/javascript">

The type attribute is required in HTML 4.

HTML comments are not needed in Javascript.
function popup(picName, chatWidth, chatHeight) {

Your global function is called "popup" ...
popup = window.open('/popup.html','popup','left=50,top=50');

... and here you assign a window to the global variable "popup",
overwriting the function.
var loadedPic = picName;

Why rename the variable? You can just use "picName".
while(popup.document.readyState != "complete") {}

Busy-waiting is a bad idea. It takes up ressources and binds the
browser until it finishes (if it does!).

If you insist on waiting until readyState goes "complete" (how many
browsers supports that? Mozilla and Netscape 4 doesn't.)
popup.resizeTo(chatWidth,chatHeight);
popup.document.images.src=loadedPic;

Which image? I think you mean
popup.document.images[0].src = picName;
popup.focus();
};
//-->
</style></head><body>
<A href="javaScript:popup('largePic.jpg','750','392')"><IMG
src="smallPIc.jpg" align=center></A>

Don't use the javascript: pseudo protocol.
<URL:http://jibbering.com/faq/#FAQ4_24>

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top