By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,400 Members | 1,322 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,400 IT Pros & Developers. It's quick & easy.

popup error (javascript)

P: n/a
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>


Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Ben Wan" <bw******@rogers.com> writes:
<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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.